简体   繁体   English

SSL证书打破了CSS

[英]SSL certificate breaks CSS

Recently purchased a SSL certificate but it looks like the website won't load the site CSS. 最近购买了SSL证书,但看起来该网站不会加载网站CSS。 This is the link, https://www.rentpayment.com/ By viewing the Console error message, this seems to be the issue: 这是链接, https://www.rentpayment.com/通过查看控制台错误消息,这似乎是问题:

<link rel="stylesheet" href="http://www.rentpayment.com/wp-content/themes/rentpayment/style.css?ver=1.0" />

Obviously changing the http to https would solve the problem, however, this is what I have in the header.php file: 显然将http更改为https可以解决问题,但是,这是我在header.php文件中的内容:

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>?ver=1.0" />

Can I add https to the dynamic field in header.php or is the problem elsewhere? 我可以将https添加到header.php中的动态字段中,还是其他地方的问题?

The SSL did not break the CSS file; SSL没有破坏CSS文件; you need to make sure the CSS file loads under https and not http. 你需要确保CSS文件加载在https而不是http。 If you look at your site with browser dev tools, you will see that many images and other resources like scripts are not loading via https. 如果您使用浏览器开发工具查看您的站点,您将看到许多图像和其他资源(如脚本)未通过https加载。

The bloginfo function - as well as others - pull the site URL from the WordPress site settings in Dashboard>General, WordPress Address (URL) and Site Address (URL), both which are stored in the wp_options table in the database. bloginfo功能 - 以及其他功能 - 从仪表板>常规,WordPress地址(URL)和站点地址(URL)中的WordPress站点设置中提取站点URL,这两者都存储在数据库的wp_options表中。 Change those two URLs to https, either in WordPress or in the database via Adminer or PHPMyAdmin. 通过Adminer或PHPMyAdmin将这两个URL更改为WordPress或数据库中的https。 Make a backup of your database beforehand. 事先备份数据库。

But be aware that you need to change all URLs in the database, such as image URLs in posts and pages. 但请注意,您需要更改数据库中的所有URL,例如帖子和页面中的图像URL。 Use https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ that will correctly change URLs and minimize breakage. 使用https://interconnectit.com/products/search-and-replace-for-wordpress-databases/将正确更改URL并最大限度地减少破损。

But your theme options may still break when changing URLs in the database, and you may need to reset them. 但是,在更改数据库中的URL时,您的主题选项可能仍会中断,您可能需要重置它们。 And, other things may break; 而且,其他事情可能会破裂; make a backup of your database beforehand. 事先备份数据库。

After that, use dev tools to look for other elements that may still be http, like hardcoded links in the theme files, so your site will be fully https and users won't see "insecure element" errors. 之后,使用开发工具查找可能仍为http的其他元素,如主题文件中的硬编码链接,这样您的网站将完全https,用户将看不到“不安全元素”错误。

I like to use the Better Search Replace WordPress plugin after I have enabled an SSL certificate to make sure to change all of the URLs in the database. 我启用SSL证书后,我喜欢使用Better Search Replace WordPress插件,以确保更改数据库中的所有URL。 https://wordpress.org/plugins/better-search-replace/ https://wordpress.org/plugins/better-search-replace/

In this case, I would search for: 在这种情况下,我会搜索:

http://www.rentpayment.com

And replace it with: 并替换为:

https://www.rentpayment.com

Definitely make a backup before performing this operation. 在执行此操作之前,请务必进行备份。

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

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