dersimn
dersimn

Reputation: 875

Why do we need the <Directory> in Apache .conf file?

Simple question:

<VirtualHost *:80>
    ServerName notes.example.com
    DocumentRoot /var/www/notes

    <Directory "/var/www/notes">
        Require all granted
        Options +Indexes
    </Directory>
</VirtualHost>

On first sight this works exactly like just putting:

<VirtualHost *:80>
    ServerName notes.example.com
    DocumentRoot /var/www/notes
</VirtualHost>

So why do we need this <Directory> statement anyway?

I've found several examples on the web of which some were using the <Directory> or <Proxy> thing and others were just putting their settings under the <VirtualHost> branch.

Upvotes: 2

Views: 35

Answers (1)

drj
drj

Reputation: 573

Because you can define particular parameters for particular directories.

You could do

<Directory "/var/www/notes/private">
   Options -Indexes
<Directory>

or something similar. DocumentRoot will work by itself, but if you want to add directory options, you'll need to use the Directory tag.

Upvotes: 1

Related Questions