Very simple request.
The management directory is encrypted in the website using .htaccess. However, for some reasons, some files need to be accessed directly without entering a password.
The premise is that cannot move files and can only modify .htaccess to meet the requirements.
Of course, since it is only a partial file and the number is small, even the file name that needs to be determined is acceptable. Of course, it would be better if permissions could be given to all suffixes of a certain type.
PHP中文网2017-05-16 17:06:41
Since you want a type of suffix to be open, it is much easier to implement, for example, you only want .txt to be accessible
<filesMatch "(?<!\.txt)$"> #hint: pcre look behind AuthUserFile /home/felix021/wwwroot/test/.htpasswd AuthName "Secret Stuff" AuthType Basic require valid-user </filesMatch>Ignore the following, for reference only
The following is a more verbose method that I thought of before.
First execute this command to get all file extensions:
find -type f -exec basename {} ; | cut -d. -f2 | sort | uniq
For example, output
jpg
js
txt
php
png
For example, if you hope that txt does not require a password and everything else is required, then modify .htaccess:
<filesMatch "\.(jpg|js|php|png)$"> #这里不写txt AuthUserFile /home/felix021/wwwroot/test/.htpasswd AuthName "Secret Stuff" AuthType Basic require valid-user </filesMatch>