我想在某些页面上添加登录限制,例如。
www.example.com/testing
每当有人点击此网址时,都应该询问密码,否则整个网站都应该免费使用密码。
Htaccess代码:
SetEnvIfNoCase Request_URI ^/testing-softwares SECURED
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user
Satisfy any
Order Allow,Deny
Allow from all
Deny from env=SECURED
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /nrl_shareware/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /abc_shareware/index.php [L]
</IfModule>
# END WordPress
Htpasswd代码:
test:$apr1$O9AK9s5s$H0IuOqkTnB0yJ5k35kX2a1
更新代码
SetEnvIfNoCase Request_URI ^/testing-softwares SECURED
AuthName "Restricted Area"
AuthType Basic
AuthUserFile "D:/DONT DELETE 80-261209/ABCProjects/xampp/htdocs/abc_shareware/.htpasswd"
AuthGroupFile /
Require valid-user
Satisfy any
Order Allow,Deny
Allow from all
Deny from env=SECURED
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /abc_shareware/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /abc_shareware/index.php [L]
</IfModule>
# END WordPress
答案 0 :(得分:0)
您可以使用mod_setenvif
:
SetEnvIfNoCase Request_URI ^/testing SECURED
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user
Satisfy any
Order Allow,Deny
Allow from all
Deny from env=SECURED