简体   繁体   中英

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM