[英]Force https to http redirect except for Wordpress /wp-admin directory
Our HTTPS
site is indexed on Google. 我们的
HTTPS
网站已在Google上建立索引。 We need this redirected to HTTP
. 我们需要将此重定向到
HTTP
。 We're using the following code: 我们正在使用以下代码:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>
to redirect https
to http
, and it works fine. 将
https
重定向到http
,它可以正常工作。
However, I want to exclude all of Wordpress admin from the https
to http
redirect, as I'd like to keep Wordpress admin working over https
, so I added: 但是,我想从
https
到http
重定向中排除所有Wordpress admin,因为我想让Wordpress admin在https
工作,所以我添加了:
RewriteCond %{REQUEST_URI} !^wp-admin
taking the .htaccess code to: 将.htaccess代码用于:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^wp-admin
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</IfModule>
Unfortunately this does not work, and trying to load /wp-admin
over https
results in too many redirects and the Wordpress dashboard does not load. 不幸的是,这不起作用,尝试通过
https
加载/wp-admin
导致重定向过多,并且Wordpress仪表板也无法加载。
www.example.com redirected you too many times.
www.example.com重定向您太多次。
Would appreciate some help in excluding /wp-admin from the https
to http
redirect. 希望能将/ wp-admin从
https
排除到http
重定向中提供帮助。
Try the following, this should force everything to HTTP except for the directory wp-admin: 请尝试以下操作,这将强制将所有内容都强制为HTTP,但目录wp-admin除外:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{REQUEST_URI} ^\/(wp-admin)
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTP:X-Forwarded-SSL} =on
RewriteCond %{REQUEST_URI} !^\/(wp-admin)
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
If you have problems with the above, you can try this also: 如果您对上述内容有疑问,也可以尝试以下操作:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/wp-admin
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.