.htaccess与wordpress中wp-login.php的重定向和身份验证用户有关的问题

.htaccess与wordpress中wp-login.php的重定向和身份验证用户有关的问题,wordpress,apache,.htaccess,redirect,Wordpress,Apache,.htaccess,Redirect,我们切换了我们的域/站点,并将流量从旧站点重定向到新站点,但我们通过.htaccess将Wordpress博客保留在旧站点上。在Wordpress中,我们有另一个.htaccess密码保护'wp login.php',但如果它处于活动状态,它会将请求重定向到我们的新站点 /home/user/public_html/.htaccess # -FrontPage- RewriteEngine on RewriteCond %{REQUEST_URI} !^/(blog|blog/wp-admin.

我们切换了我们的域/站点,并将流量从旧站点重定向到新站点,但我们通过.htaccess将Wordpress博客保留在旧站点上。在Wordpress中,我们有另一个.htaccess密码保护'wp login.php',但如果它处于活动状态,它会将请求重定向到我们的新站点

/home/user/public_html/.htaccess

# -FrontPage-
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(blog|blog/wp-admin.php|blog/wp-admin|blog/wp-login.php)
RewriteRule ^.*$ http://www.newwebsite.com/

AuthUserFile /home/user/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/user/public_html/_vti_pvt/service.grp


# Begin password protection #
# End password protection #
...
<Files wp-login.php>
AuthUserFile /home/user/public_html/blog/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
</Files>
/home/user/public_html/blog/.htaccess

# -FrontPage-
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(blog|blog/wp-admin.php|blog/wp-admin|blog/wp-login.php)
RewriteRule ^.*$ http://www.newwebsite.com/

AuthUserFile /home/user/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/user/public_html/_vti_pvt/service.grp


# Begin password protection #
# End password protection #
...
<Files wp-login.php>
AuthUserFile /home/user/public_html/blog/.htpasswd
AuthName "Private access"
AuthType Basic
require valid-user
</Files>

AuthUserFile/home/user/public\u html/blog/.htpasswd
AuthName“私有访问”
AuthType Basic
需要有效用户

如何继续保护wp登录并允许其正确重定向?

此配置应能正常工作。首先处理根目录中的
.htaccess
文件,如果不匹配,将重定向到新站点。如果未执行重定向,并且加载了
/blog/wp login.php
页面,则第二个
.htaccess
文件应处理并触发基本身份验证提示

您的
.htaccess
重定向也可以简化,因为您只需要确保URL路径不以
/blog/
开头。如果没有匹配项,您可以使用
匹配项重定向到新站点

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule . http://www.newwebsite.com/