Beginner Fundamentals
Directory Blocks
A <Directory> block applies settings to a specific folder and everything inside it. This is where you control behavior, overrides, and access.
Basic Block
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Options
Options enables features for that directory:
Indexes: show a file list when no index file exists.FollowSymLinks: allow symbolic links to be followed.-Indexes: a minus sign turns a feature off.
Options -Indexes +FollowSymLinks
AllowOverride
This controls whether .htaccess files in the folder may override settings:
None: ignore.htaccess(faster, recommended).All: allow all overrides.
Require
Require sets access control in Apache 2.4:
Require all granted # allow everyone
Require all denied # block everyone
Apply Changes
sudo apache2ctl configtest
sudo systemctl reload apache2
Directory blocks are the main tool for shaping how each part of your site behaves.