Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<VirtualHost *:80>
    DocumentRoot /var/www
    <Directory />

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

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

share|improve this question
up vote 2 down vote accepted

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 "/home">
  AllowOverride FileInfo 

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: http://httpd.apache.org/docs/current/mod/core.html#directory

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.