1

i want to know how to have access some files in special directory which is need to be authenticate with apache web server this is my config file

<Directory /var/www/media>
    Order deny,allow
    AuthType            Basic
    AuthName            "Restricted Files"
    AuthUserFile        htpasswd
    Require user        ABC
    Options +Indexes
</Directory>

inside the media folder i have folder named temp and inside temp there are some pdf files i want to access them without entering password or access from url like this "www.example.com/media/temp/abc.pdf"

H00man
  • 375
  • 1
  • 7
  • 21

2 Answers2

1

Inside /var/www/media/temp/.htaccess have these 2 lines:

Satisfy Any
Allow from all

This will disable Basic Auth for whole /var/www/media/temp/ directory and all files under it. However if you want to disable only for /var/www/media/temp/*.pdf files then you need more code using mod_setenvif as this:

SetEnvIfNoCase Request_URI \.pdf$ NO_AUTH

Satisfy    any
Order      deny,allow
Deny from  all
Allow from env=NO_AUTH
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

Just define new rules for subfolder:

<Directory /var/www/media/temp>
    Order allow,deny
    Satisfy Any
    Allow from all
</Directory>
Mark Shevchenko
  • 7,937
  • 1
  • 25
  • 29