Apache: deny acces to directory but allow 1 file

5,820

Files tag must use relative path to Directory. With absolute path (<Files /var/www/abc/README.txt>) it doesn't work.

This works:

<Directory /var/www/abc/*>
    Order allow,deny
    deny from all
    <Files README.txt>
        order allow,deny
        allow from all
    </Files>
</Directory>
Share:
5,820

Related videos on Youtube

martin
Author by

martin

Updated on September 18, 2022

Comments

  • martin
    martin over 1 year

    I am using Apache 2.2.22 on Ubuntu 12.04.

    I need to disable access to directory /var/www/abc/ but allow access to file inside this directory /var/www/abc/README.txt. I try:

    <Directory /var/www/abc/*>
        Order allow,deny
        deny from all
        <Files /var/www/abc/README.txt>
            order allow,deny
            allow from all
        </Files>
    </Directory>
    

    But it doens't work - acess to directory is disabled (ok) and file is to disabled (not ok).

    What I do bad?

    • alexus
      alexus about 9 years
      Try to move <Files> outside of <Directory>
    • martin
      martin about 9 years
      I tried move Files outside Directory and it doesn't work.