2016-03-07 40 views
0

我想打一些网页使用密码保护的htpasswd的如何配置的htpasswd与htaccess的

我该怎么办呢?

# 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服务器错误

+0

你不应该将.htpasswd文件放在public_html中!!! – kingtut007

+0

你可以给我一个代码如何使用.htpasswd? –

+0

请看下面..... – kingtut007

回答

0

将下面的代码在.htaccess中的public_html

AuthType Basic 
AuthName "Password Protected Area" 
AuthUserFile /path/to/.htpasswd 
Require valid-user 

然后创建一个htpasswd的,但把它OUTSIDE的public_html

所以/path/to/.htpasswd指向该位置

-1

它很可能我想得简单在这里,但不应该代码:

AuthUserFile /home1/thetimh6/public_html/htpasswd 

为:

AuthUserFile /home1/thetimh6/public_html/.htpasswd 
+0

不行不行你可以点击这里https://www.thetimelesspearlwholesale.com/product-category/earrings,用户名和密码是admin –