无法在使用 SSL 的服务器中获取 css 和 js 文件
Can not get css and js files in the server that use SSL
我在 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
例如$config['base_url'] = "https://www.xxxx.com/"
还是会发生,如何调试修复?感谢您的帮助
您的错误消息中包含所有内容:
This request has been blocked; the content must be served over HTTPS.
您的 html 到 'http' 中似乎有静态 link。因此,不要像那样在 html 中直接使用协议:
http://www.xxxx.com/assets/font-awesome/css/font-awesome.css
改成这样:
assets/font-awesome/css/font-awesome.css
另请记住,如果您尝试使用未配置为通过 https 提供内容的其他域中的 JS 或 CSS,您将遇到此问题。
喜欢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")
我在 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例如$config['base_url'] = "https://www.xxxx.com/"
还是会发生,如何调试修复?感谢您的帮助
您的错误消息中包含所有内容:
This request has been blocked; the content must be served over HTTPS.
您的 html 到 'http' 中似乎有静态 link。因此,不要像那样在 html 中直接使用协议:
http://www.xxxx.com/assets/font-awesome/css/font-awesome.css
改成这样:
assets/font-awesome/css/font-awesome.css
另请记住,如果您尝试使用未配置为通过 https 提供内容的其他域中的 JS 或 CSS,您将遇到此问题。
喜欢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")