htaccess <Directory> deny from all

Keverw picture Keverw · Dec 30, 2011 · Viewed 124k times · Source

I've been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes which i didn't see anypoint of allowing any Directory viewing so moved that to the main one. so now i only have 2 .htaccess files. the main and one in /system which holds

# Block External Access
deny from all

So i wanted to run that on /system only from within the main. So i deleted the one in /system and added

 # Block External Access
<Directory "/system/">
deny from all
</Directory>

to my main .htaccess file leaving 1!

but now i get a

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.17 (Ubuntu) Server at 10.0.1.5 Port 80

The goal is to block reading any files in /system and it's sub directory's but allow viewing of everything else all from one .htaccess file for the whole project. Any ideas on how i can fix this? I did some Google searches but couldn't really come out with anything.

Answer

Ulrich Palha picture Ulrich Palha · Dec 30, 2011

You cannot use the Directory directive in .htaccess. However if you create a .htaccess file in the /system directory and place the following in it, you will get the same result

#place this in /system/.htaccess as you had before
deny from all