Mobile app version of vmapp.org
Login or Join
Jessie594

: What is the purpose of with a local <VirtualHost *:80> DocumentRoot /var/www <Directory /> </Directory> </VirtualHost> Does the <Directory> tag refer

@Jessie594

Posted in: #Apache2 #Configuration #HttpdConf

<VirtualHost *:80>
DocumentRoot /var/www
<Directory />
</Directory>
</VirtualHost>


Does the <Directory> tag refer to /var/www on the server, or /?

What would be the purpose of having a / configuration on a VirtualHost?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

1 Comments

Sorted by latest first Latest Oldest Best

 

@Candy875

Apache applies configurations for directories to a request from smallest to largest. In essence the <Directory /> section specifies virtual host defaults; since every other possible directory will have that portion in its path.


If multiple (non-regular expression) sections match the
directory (or one of its parents) containing a document, then the
directives are applied in the order of shortest match first,
interspersed with the directives from the .htaccess files. For
example, with


<Directory />
AllowOverride None
</Directory>

<Directory "/home">
AllowOverride FileInfo
</Directory>



for access
to the document /home/web/dir/doc.html the steps are:


Apply directive AllowOverride None (disabling .htaccess files).
Apply directive AllowOverride FileInfo (for directory /home).
Apply any FileInfo directives in /home/.htaccess, /home/web/.htaccess and
/home/web/dir/.htaccess in that order.



BTW, in the above example <Directory /home/web> would've worked the exact same way. The reason that isn't usually used though is because doing so will make moving your site to a new directory a little more difficult. It's easier to just use <Directory /> since that will work no matter where the site root is.

There is a full explanation on the Apache site: httpd.apache.org/docs/current/mod/core.html#directory

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme