如何使用 htaccess 配置 htpasswd
How to config htpasswd with htaccess
我想使用 .htpasswd 对某些页面进行密码保护
我该怎么做??
# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/product-category/ require_auth=true
# Auth stuff
AuthUserFile /home1/thetimh6/public_html/htpasswd
AuthName "Password Protected"
AuthType Basic
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth
我正在我的 htaccess 文件中尝试它,但它显示给我
500 服务器错误
很有可能我在这里想的太简单了,但是代码不应该:
AuthUserFile /home1/thetimh6/public_html/htpasswd
是:
AuthUserFile /home1/thetimh6/public_html/.htpasswd
在public_html
中的.htaccess中放入以下代码
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user
然后创建一个.htpasswd,但是把它放在外面public_html
所以 /path/to/.htpasswd 指向那个位置
我想使用 .htpasswd 对某些页面进行密码保护
我该怎么做??
# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/product-category/ require_auth=true
# Auth stuff
AuthUserFile /home1/thetimh6/public_html/htpasswd
AuthName "Password Protected"
AuthType Basic
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth
我正在我的 htaccess 文件中尝试它,但它显示给我
500 服务器错误
很有可能我在这里想的太简单了,但是代码不应该:
AuthUserFile /home1/thetimh6/public_html/htpasswd
是:
AuthUserFile /home1/thetimh6/public_html/.htpasswd
在public_html
中的.htaccess中放入以下代码AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user
然后创建一个.htpasswd,但是把它放在外面public_html
所以 /path/to/.htpasswd 指向那个位置