How would I require a password for all files except one using .htaccess?

依然范特西╮ 提交于 2019-12-04 01:36:57
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/file/.htpasswd
AuthGroupFile /dev/null

<Files "*">
Require valid-user
</Files>

<Files "index.html">
Allow from all 
Satisfy any
</Files>
Darryl Hein

I used empi response almost exactly, but I realized that I'm loading a logo and reset-min.css on the under construction page, so I modified it like the following:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/examplecom/example.com/html/.htpasswd
AuthGroupFile /dev/null

<Files "*">
Require valid-user
</Files>

<FilesMatch "(index\.html|reset-min\.css|logo-temp\.gif)$">
Allow from all
Satisfy any
</FilesMatch>

have you tried reversing the order to first allow, then deny? For further reading: apache htaccess directive are a good reference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!