简体   繁体   English

将完整的wordpress网站转换为HTTPS

[英]Convert a full wordpress site to HTTPS

I'm trying to get a wordpress site to HTTPS, but everything I try gives me a redirect loop. 我正在尝试将一个wordpress网站用于HTTPS,但我尝试的一切都给了我一个重定向循环。 I've edited the htaccess, I've set it in PHP, I've even downloaded a wordpress plugin to convert it, but every method gives me a redirect loop error. 我编辑了htaccess,我用PHP设置它,我甚至下载了一个wordpress插件来转换它,但每个方法都给我一个重定向循环错误。 I know that something has to be redirecting my https to http, but I don't know what. 我知道有些东西必须将我的https重定向到http,但我不知道是什么。 Here is my .htaccess file without any of the HTTPS settings in it: 这是我的.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

And here's the PHP I'm trying to use in the header php file to conver the page to HTTPS: 这里是我试图在头文件php文件中使用的PHP将页面转换为HTTPS:

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

You don't need a blanket redirect in .htaccess or in PHP. 您不需要在.htaccess或PHP中进行全面重定向。 Go to Dashboard >> Settings and change your URLs to https. 转到信息中心>>设置,然后将您的网址更改为https。 Then save permalinks. 然后保存永久链接。

You may want to find/replace any http URLs in post/page content, media URLs, etc, so you don't get redirects for those from http to https. 您可能希望查找/替换帖子/页面内容,媒体URL等中的任何http URL,因此您无法获得从http到https的重定向。 Try interconnectit.com WordPress Serialized PHP Search Replace Tool 尝试使用interconnectit.com WordPress序列化的PHP搜索替换工具

After https is working, use Firebug with Firefox, or use the developer tools in Chrome or Safari or IE to see if you are getting any "insecure content" errors from non-https URLs in any theme files. 在https工作之后,使用Firebug和Firefox,或使用ChromeSafariIE中的开发人员工具查看您是否从任何主题文件中的非https网址获得任何“不安全内容”错误。

You may need to change to a relative path for images in CSS files, ie background-image: url(http://example.com/themes/wp-content/theme/images/image.jpg) to background-image: url(images/image.jpg) 您可能需要更改为CSS文件中图像的相对路径,即background-image: url(http://example.com/themes/wp-content/theme/images/image.jpg)background-image: url(images/image.jpg)

And, you may need to remove the http from absolute paths in php theme files, ie change 'http://example.com/image.jpg' to '//example.com/image.jpg' ; 并且,您可能需要从php主题文件中的绝对路径中删除http ,即将'//example.com/image.jpg' 'http://example.com/image.jpg'更改为'//example.com/image.jpg' ; that will allow your resources to default to https. 这将允许您的资源默认为https。

Go to general settings and change WordPress Address from http to https 转到常规设置并将WordPress地址从http更改为https

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

You also may try this plugin 您也可以尝试这个插件

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM