2016-03-07 36 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 –