我使用.htaccess 在我的WC网站上进行基本身份验证,以帮助防止黑客访问wp-login, 效果很好。。。除WooCommerce外,如果登录的客户想要从其帐户注销-单击注销链接后,他们会收到基本的身份验证弹出窗口,要求他们“授权”(由我们的.htaccess).
在Woocommerce仪表板上:
您好MrTest(不是MrTest?注销)<<;单击“注销”将打开基本身份验证登录框。。。。我们如何避免这种情况?
以下是htaccess的内容:
<FilesMatch "wp-login.php">
AuthName "Authorized"
AuthType Basic
AuthUserFile /home/user/.pswrdfile
require valid-user
</FilesMatch>
在WooCommerce设置中,注销端点为:
customer-logout 注销链接URL显示:
example.com/shop/my-account/customer-logout/?_wpnonce=2e343434
那么如何改变
.htaccess 允许
wp-login.php?action=logout 通过基本认证?
我试过了,但没有成功;我有最新版本的Apache服务器。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-login.php$
RewriteCond %{QUERY_STRING} ^action=logout
RewriteRule ^ - [E=noauth]
<FilesMatch "^(wp-login.php)">
Options -Indexes +FollowSymLinks +MultiViews
AuthName "Protected page. If you are not allowed to be here, leave the page"
AuthType Basic
AuthUserFile "/etc/apache2/htaccess/myhtaccess"
Require valid-user
Order Deny,Allow
Deny from all
Allow from env=noauth
Satisfy any
</FilesMatch>
SO网友:Earlee
从中的答案Password protect a specific URL, 我们可以扭转这种状况。引用他的回答,
您应该能够使用mod_env 以及Satisfy any 指令。您可以使用SetEnvIf 对照Request_URI, 即使这不是一条物理路径。然后可以检查变量是否设置在Allow 陈述因此,您需要使用密码登录,或者Allow 无需密码即可进入:
# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/shop/my-account/customer-logout/ require_auth=false
# Auth stuff
AuthUserFile /var/www/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