Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude one file from password protection in .htaccess

I have the following code to protect files with password in .htaccess:

<FilesMatch "\.(html|htm|css|js|php|swf|swz|xml|ico|jpg|jpeg|png|txt)$">
AuthName "Member Only"
AuthType Basic
AuthUserFile /path/to/password/.htpasswd
require valid-user
</FilesMatch>

How can I exclude from here the should_be_excluded.php from being password protected? I can change the protection lines if needed, but I think that something could be done in the regex?

like image 517
Centurion Avatar asked Oct 12 '22 13:10

Centurion


1 Answers

how about something like:

<FilesMatch "\.(html|htm|css|js|php|swf|swz|xml|ico|jpg|jpeg|png|txt)$">
    AuthName "Member Only"
    AuthType Basic
    AuthUserFile /path/to/password/.htpasswd
    require valid-user
</FilesMatch>
<Files /should_be_excluded.php>
    Order Allow,Deny
    Allow from all
</Files>

this should allow ALL access to the excluded file?

like image 69
Marty Avatar answered Nov 16 '22 13:11

Marty