我在 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”的静态链接。所以不要像那样直接在你的 html 中使用协议(protocol):
http://www.xxxx.com/assets/font-awesome/css/font-awesome.css
改成这样:
assets/font-awesome/css/font-awesome.css
另请记住,如果您尝试使用未配置为通过 https 提供内容的其他域中的 JS 或 CSS,您将遇到此问题。
关于javascript - 无法在使用 SSL 的服务器中获取 css 和 js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29740300/