In Apache's .htaccess directory encryption, setting a file individually does not require a password.
为情所困
为情所困 2017-05-16 17:04:41
0
1
632

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.

为情所困
为情所困

reply all(1)
洪涛

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>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template