WordPress http 到 https 重定向

标签 wordpress apache ssl https

我有一个实现了 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/

相关文章:

wordpress - 如何从永久链接(漂亮的网址)获取帖子 ID?

php - 如何解析 mySql 表的单个字段中的多个值?

css - 图片覆盖完整的 div CSS

linux - zabbix 前端 web 界面给出错误 404 (ubuntu server 14.04)

php - 使用 PHP 需要通过 TLS 的显式 FTP

ssl - 如何强制或重定向我的 next.js 网站以使用 https

css 媒体在桌面浏览器开发人员模式下工作,但在实际的 iphone 6s 上不工作

apache - httpd 未在启动时运行

Tomcat 的 Apache (httpd) 代理不断超时

ssl - VoIP 上的 DTLS 实现