Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache - How to deny directory but allow one file in that directory

I try to configure my Apache .conf file to deny listing from a certain category, but I want to allow a specific file inside this category. It appears that the Directory rule is "stronger" than the Files rule, so when using both - I can't access that certain file.

This is what I try:

<Directory /var/www/denied_directory>      order deny,allow      Deny From All </Directory>  <Files safefile.php>     Order Allow,Deny     Allow from All </Files> 
like image 780
Maor Barazany Avatar asked Jun 05 '11 15:06

Maor Barazany


People also ask

How do I restrict access to a folder in Apache?

Just add a . htaccess file with the code Deny from all to the folder.

What does htaccess Deny from all do?

You just need to add a few commands to . htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.


1 Answers

It works perfectly if it is configured properly:

   <Directory /var/www/denied_directory>         Order allow,deny         <Files test.php>            Order deny,allow         </Files>    </Directory> 
like image 62
akond Avatar answered Sep 28 '22 04:09

akond