我的Wordpress网站在https://www.example.com
Settings/general
我正在使用Simple SSL
插件。这是我的.htaccess
。
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteCond %{HTTP_HOST} =example.com
#RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} wp-admin
RewriteRule ^(.*)$ https://www.example.com/wp-admin/ [R,L]
</IfModule>
# BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.22]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
出于某种原因,当转到example.com
时,它会从http-&gt; https-&gt; http-&gt; https
example.com
https://example.com
http://www.example.com
https://www.example.com
答案 0 :(得分:0)
如果X-Forwarded-Proto是确定请求是否来自HTTPS的方式,我相信您可以用以下内容替换所有内容:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://www.example.org%{REQUEST_URI} [R=301,L]
</IfModule>
将它放在.htaccess中的WP块之前。如果直接在Apache中处理SSL,请将RewriteCond行替换为RewriteCond %{SERVER_PORT} 80