Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my goal is to deny access to certain sub-directories. my localhost configuration allows overriding like that:

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

I also have an .htaccess file in /var/www/ with contents:

    <Directory /var/www/*>
            Order allow,deny
            allow from all
    </Directory>

Those rules above state access to everyone, but my server responds with internal error. "cat /var/log/apache2/error.log | tail -n 10" gives:

    [Thu Feb 23 12:41:09 2012] [alert] [client 127.0.0.1] /var/www/.htaccess: <Directory not allowed here"

Why is that so ? Any links on extensive guides on this problem are also extremely appreciated. Thanks.

share|improve this question
    
Who are you trying to deny access to? –  toomanyairmiles Feb 23 '12 at 11:50
add comment

migrated from webmasters.stackexchange.com Feb 23 '12 at 12:16

This question came from our site for pro webmasters.

1 Answer

The reason you are getting that error message is because the <Directory> directive is only valid in the main Server config or a Virtual Host config and is not valid in a .htaccess file.

As to how to deny access, very simply you can set the permissions on the directories so that your apache cannot read them. More sophisticated methods would require that you tell us what you are trying to deny access from.

share|improve this answer
add comment

Your Answer

 
discard

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