欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

浏览器报Mixed Content错误的解决:Mixed content: load all resources via HTTPS to improve the security of your site 有大用 有大大用

Even though the initial HTML page is loaded over a secure HTTPS connection, some resources like images, stylesheets or scripts are being accessed over an insecure HTTP connection. Usage of insecure resources is restricted to strengthen the security of your entire site.

To resolve this issue, load all resources over a secure HTTPS connection.


https地址中,如果加载了http资源,浏览器将认为这是不安全的资源,将会默认阻止,这就会给你带来资源不全的问题了,比如:图片显示不了,样式加载不了,JS加载不了。

控制台报错:

Mixed content: load all resources via HTTPS to improve the security of your site
控制台报错
控制台报错

解决方案:

第一种

  1. 首先确定引入的资源可以在http和https下都能访问


https://xxx.com/index.php/Index/index.html

http://xxxx.hyaomall.com/index.php/Index/index.html
  1. 在head里面写类似相对路径的形式


<script src="//xxx.com/js/jquery-1.6.0.js" type="text/javascript"></script>

第二种

  1. 在页面中加入(meta)头中添加upgrade-insecure-requests


<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  1. 这将会把http请求转化为https请求。这样就不会再出现Mixed Content的错误了。

我使用的是第二种


来自 https://www.cnblogs.com/depressiom/p/17083006.html



普通分类: