简体   繁体   English

来自Codeigniter网站上的Javascript文件中通过HTTP提供的内容不安全的内容警告

[英]Insecure Content Warning for content served over http from Javascript File on Codeigniter Site

Google Chrome is returning an insecure content warning for content served on some of my pages. Google Chrome浏览器针对我的某些页面上提供的内容返回了不安全的内容警告。 The content is called by a Javascript file in the assets/js directory in Codeigniter. 内容由Codeigniter中Assets / js目录中的Javascript文件调用。 The Javascript file is loaded in the footer by reference to the js_asset_url, set out in the asset_helper file. 通过引用asset_helper文件中列出的js_asset_url将Javascript文件加载到页脚中。

<script src="<?php echo js_asset_url('script.js'); ?>"></script>

I only use SSL on specific controllers, hence the assets folder content is currently loaded insecurely and worries users due to the warning displayed. 我仅在特定控制器上使用SSL,因此资产文件夹内容当前不安全地加载,并且由于显示警告而使用户担心。 Does anyone have a solution for Codeigniter to force assets such as .js files to load via SSL? 有没有人为Codeigniter提供一种解决方案,以通过SSL强制加载.js文件等资产?

EDIT: I finally fixed using an external reference source (hope it's ok to post the link!) http://www.davidnard.com/2011/04/easy-ssl-redirection-in-codeigniter/ The content being called by the .js file was for 2 functions within a controller. 编辑:我终于使用外部参考源进行了修复(希望可以发布链接!) http://www.davidnard.com/2011/04/easy-ssl-redirection-in-codeigniter/内容由.js文件用于控制器中的2个功能。 Setting the relevant controller in the $partial array (see above link) did the trick. 在$ partial数组中设置相关的控制器(请参见上面的链接)可以解决问题。

If I am using an absolute URL to point to a script file, I usually reference it via https instead of http. 如果我使用绝对URL指向脚本文件,通常会通过https而不是http来引用它。 Such as with jQuery, I reference via 例如使用jQuery,我通过

If I'm using standard HTTP protocols, my browser doesn't care I'm trying to access secured content, and it is properly handled for using HTTPS. 如果我使用的是标准HTTP协议,则我的浏览器不会在乎我尝试访问受保护的内容,并且可以正确使用HTTPS对其进行处理。

To handle this with your code, you could always do a string replace. 要使用您的代码处理此问题,您始终可以执行字符串替换。

For instance, in your case, you could do something like: 例如,在您的情况下,您可以执行以下操作:

<!-- str_replace([needle], [replacement_text], [haystack]); -->
<script src="<?php echo str_replace('http:', 'https:', js_asset_url('script.js')); ?>"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Deezer内容通过HTTP提供 - Deezer content is served over HTTP API 数据超过 http 在通过 https 提供服务的站点中,脚本有“混合内容”错误 - API data over http in site served over https, script has “mixed content” error 浏览器什么时候在SSL站点上抛出内容不安全警告 - At what point does a browser throw and insecure content warning on an SSL site Codeigniter - jquery.min.js:4 混合内容:内容必须通过 HTTPS 提供 - Codeigniter - jquery.min.js:4 Mixed Content: the content must be served over HTTPS 从Javascript中检测损坏的锁定图标(混合安全/不安全内容) - Detect broken lock icon (mixed secure/insecure content) from Javascript Chrome的Javascript / JQuery事件阻止了不安全的内容 - Javascript/JQuery event for Chrome blocking insecure content 警告:页面index.html运行了不安全的内容 - Warning : The page index.html ran insecure content 具有相对URL的AJAX调用将通过HTTPS服务的网站的HTTP传递给 - AJAX calls with relative URLs are going to HTTP for a site served over HTTPS 使用javascript从外部站点获取内容 - Use javascript to fetch content from external site 使用javascript在后台读取网站内容 - Reading content from site in background using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM