将完整的 wordpress 站点转换为 HTTPS

Convert a full wordpress site to HTTPS

我正在尝试将 wordpress 站点连接到 HTTPS,但我尝试的所有操作都给我一个重定向循环。我编辑了 htaccess,我在 PHP 中设置了它,我什至下载了一个 wordpress 插件来转换它,但是每种方法都给我一个重定向循环错误。我知道必须将我的 https 重定向到 http,但我不知道是什么。这是我的 .htaccess 文件,其中没有任何 HTTPS 设置:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

这里是 PHP 我试图在 header php 文件中使用以将页面转换为 HTTPS:

if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}

转到常规设置并将 WordPress 地址从 http 更改为 https

这里有更多调整https://make.wordpress.org/support/user-manual/web-publishing/https-for-wordpress/

你也可以试试这个插件

https://wordpress.org/plugins/wordpress-https/

您不需要在 .htaccess 或 PHP 中进行全面重定向。转到仪表板 >> 设置并将您的 URL 更改为 https。然后保存永久链接。

您可能想要 find/replace post/page 内容、媒体 URL 等中的任何 http URL,这样您就不会获得从 http 到 https 的重定向。尝试 interconnectit.com WordPress Serialized PHP Search Replace Tool

在 https 工作后,使用 Firebug with Firefox, or use the developer tools in Chrome or Safari or IE 查看您是否从任何主题文件中的非 https URL 收到任何 "insecure content" 错误。

您可能需要将 CSS 个文件中的图像更改为相对路径,即 background-image: url(http://example.com/themes/wp-content/theme/images/image.jpg)background-image: url(images/image.jpg)

并且,您可能需要从 php 主题文件的绝对路径中删除 http,即将 'http://example.com/image.jpg' 更改为 '//example.com/image.jpg';这将使您的资源默认为 https。