Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I'm attempting to configure an Apache HTTP Server installation and I'm having a problem getting the Deny directive to work properly in both a general or VirtualHost context for some reason.

I stripped out as much as I could to try to isolate the problem, yet even this simple case doesn't work.

The httpd.conf file is simply:

ServerName localhost

<Directory />
    Order Allow,Deny
    Deny from All

The virtual host's configuration file looks like this:

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

    <Directory />
        Order Allow,Deny
        Deny from all


Yet for some reason, the Deny directive doesn't work, and for example, loads normally when requested.

What could I be missing here? Any help would be much appreciated.

share|improve this question
Are you changing the right config file? Are you restarting the server after doing these changes? – Khaled Dec 15 '10 at 8:03
Yes I'm sure I'm using the correct configuration file, because if I change the directive to Location, access is denied as expected. I just need to get it working for Directory as well. Thanks! – Leirith Dec 15 '10 at 21:56


    <Location />
    Order Allow,Deny
    Deny from all
share|improve this answer
+1, With Directory / one would refer to the root of the filesystem, not the DocumentRoot. – weeheavy Dec 15 '10 at 13:28
Using <Location /> works correctly, however I am concerned about using it to restrict directories deeper within the webspace, because of the warning presented in the apache documentation [], which instructs never to use location for this purpose. How can I make it work using <Directory /> ? I tried using <Directory /var/www/> but that didn't work. Any advice would be appreciated. – Leirith Dec 15 '10 at 21:57

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.