javascript - 无法在使用 SSL 的服务器中获取 css 和 js 文件

标签 javascript php css codeigniter 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”的静态链接。所以不要像那样直接在你的 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/

相关文章:

javascript - 停止 Symfony 表单提交后重定向

php - 如何在php中打印数组中的输出?

php - 使用 xPath 访问 simpleXML 的值

jquery - 如何设置正在动态排序的数据表列的样式?

javascript - 从 javascript 或 jquery 更新 spring 模型值

javascript - 如何修复最新版本中的 braintree javascript 错误 "t.getVersion is not a function"

javascript - 使用 jQuery 自动加载 DIV

设置全局变量时的 PHP 语法错误

css - 将绝对元素定位在灵活的框布局框内

javascript - 国家地理编码边界 - 摆脱国家线