2013-11-28 20 views
1

我有一個網站建立在CS購物車。
管理員面板的網址是這樣的https://mysite.com/vendorsds.php
我想爲用戶設置一個HTPasswd,只要他/她訪問此鏈接https://mysite.com/vendorsds.php?dispatch=companies.update

我曾嘗試以下 -在url中爲特定的GET請求設置HTPasswd

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /var/chroot/home/content/28/11136228/html/htpasswds/.htpasswd 
AuthGroupFile /dev/null 
<Files vendorsds.php?dispatch=companies.update> 
require valid-user 
</Files> 

當我刪除從高於其工作的所有頁面通過vendorsds.php去的dispatch=companies.update。 是否可以在同一頁面上爲任何特定的GET參數(如dispatch=companies.update)設置HTPasswd

回答

0

這真的很棘手,但可能。請參閱以下2步驟方法:

## force BASIC auth for a specific query parameter 

# 1: set URI to /vendorsds.php/companies.update if query string is dispatch=companies.update 
RewriteCond %{QUERY_STRING} (?:^|&)dispatch=companies.update(?:&|$) [NC] 
RewriteRule ^(vendorsds\.php)/?$ $1/%1 [NC] 

# 2: set AUTH_NEEDED var to 1 if URI is /vendorsds.php/companies.update 
SetEnvIfNoCase Request_URI "^/vendorsds\.php/companies\.update" AUTH_NEEDED 

AuthType Basic 
AuthName "Restricted Area" 
AuthUserFile /var/chroot/home/content/28/11136228/html/htpasswds/.htpasswd 
Require valid-user 
Order allow,deny 
Allow from all 
Deny from env=AUTH_NEEDED 
Satisfy any