开发者

Only password protect one file in folder with .htaccess

I only want to password protect one file in开发者_Python百科 a folder. How can I do this with .htaccess?


Let's say you want to password protect your secret.html file. Just create a .htaccess file in the same folder as the secret file, with the following content (you may need to customize some values according to your config:

<Files secret.html>
AuthName "Login"
AuthType Basic
AuthUserFile /html/username/.htpasswd
require valid-user
</FilesMatch>

You can also use wildcards to filter some file types only. Imagine you want to password protect all zip files:

<FilesMatch "*.zip">
AuthName "Login"
AuthType Basic
AuthUserFile /html/username/.htpasswd
require valid-user
</FilesMatch>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜