Centurion
Centurion

Reputation: 5291

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?

Upvotes: 6

Views: 5056

Answers (1)

Marty
Marty

Reputation: 4657

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?

Upvotes: 4

Related Questions