我在codeigniter中实现了一个网站,最近我将它上传到有SSL的生产服务器上。
问题是,如果我使用" http"进入,一切正常。如果我使用" https" ,然后找不到所有的css和js。错误是:
Mixed Content: The page at 'https://www.xxxx.com/' was loaded over a secure connection, but contains a form which targets an insecure endpoint 'http://www.xxxx.com/secure/validate_credentials'. This endpoint should be made available over a secure connection.
Mixed Content: The page at 'https://www.xxxx.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://www.xxxx.com/assets/font-awesome/css/font-awesome.css'. This request has been blocked; the content must be served over HTTPS.
我已经在codeigniter中编辑了config.php
e.g。 $ config [' base_url'] =" https://www.xxxx.com/"
但仍然会发生,如何调试和修复它?谢谢你的帮助
答案 0 :(得分:2)
你的所有内容都有错误信息:
This request has been blocked; the content must be served over HTTPS.
您的html中的静态链接看起来像是' http'。所以不要直接在你的html中使用协议:
http://www.xxxx.com/assets/font-awesome/css/font-awesome.css
将其更改为:
assets/font-awesome/css/font-awesome.css
另外请记住,如果您尝试使用未配置为使用https提供内容的其他域中的JS或CSS,您将遇到此问题。
答案 1 :(得分:1)
赞maque说你有错误信息
但建议使用base_url()
代替site_url
来获取资源,例如css,js和图片。
你可以升级到Codeigniter 3.0 it is still in develop in the time of writing this answer
,但它在这个阶段非常稳定,它有更好的版本base_url()
和site_url()
,因为你现在可以在参数中添加协议该
site_url("assets/js/jquery.min.js", "https")