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

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


It works perfectly if it is configured properly:

   <Directory /var/www/denied_directory>        Order allow,deny        <Files test.php>           Order deny,allow        </Files>   </Directory>


In Apache 2.4, with an additional test on an environment variable for good measure:

See also: Require Directive

<Directory "/wikis/foswiki">    Require all denied    # Allow access to toplevel files ending in .html (in particular index.html) only     # (comment out if you don't care for this)    <Files ~ "\.html$">       <RequireAll>          Require all granted          Require not env blockAccess       </RequireAll>    </Files></Directory>


put your files directive inside your directory directive.