我有一个实现了 ssl 的 wordpress 网站。该网站在 https://domain.com 正常运行.我想重定向来自 http://domain.com 的所有流量至 https://domain.com .我用谷歌搜索了这个并将我的 .htaccess 更改为以下内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
重定向无效。我已经尝试过 Easy HTTPS 重定向、Wordpress HTTPS 等插件,但仍然无法正常工作。有人可以帮我解决这个问题吗? 我还想在我尝试访问 http://domain.com 时补充一点 它没有连接。 提前致谢。
最佳答案
你不需要插件来做这个......
尝试在您的 .htaccess
的 RewriteRule 中做这个小改动:
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
关于WordPress http 到 https 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37069784/