我有一个包含上午表格的网页。对于与该页面匹配的所有请求,通过Apache重定向启用HTTPS。不幸的是,由于CSS使用’background-image:url(/ images / …)’拉入外部图像,浏览器将生成一条警告消息,指出该页面包含混合内容。
解决方法
Update 2014.12.17:
Now that SSL is 07000 and 07001,this technique is now an anti-pattern. If the asset you > need is available on SSL,then always use the
https://
asset.Allowing the snippet to request over HTTP opens the door for attacks
like the 07002. It’s always safe to
request HTTPS assets even if your site is on HTTP,however the reverse
07003.More guidance and details in 07004.
资料来源:Paul Irish – The Protocol-relative URL
这是一个非常流行的解决方案:
有这个小技巧,你可以逃脱,这将节省你一些头痛:
在HTML中
<img src="//domain.com/img/logo.png">@H_403_36@在CSS中
div{background: url(//path/to/image.png);}@H_403_36@