• 懒鸟飞:帝国cms模板专业分享平台,新域名:lanniaofei.com

网页访问报错This request has been blocked; the content must be served over HTTPS.

问题:网页有时访问https网站,由于网站中一些资源是http的,网页执行会报错“This request has been blocked;  the content must be served over HTTPS.”,chrome浏览器审查元素可以看到。

解决:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

可以在相应的页面的<head>里加上这句代码,意思是自动将http的不安全请求升级为https

可以在代码中判断服务器的协议类型是否为https,再加载上述代码,如下

{yun:}if strpos($config.sy_weburl,'https')!== false{/yun}
 <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> 
{yun:}/if{/yun}
 
QQ在线咨询
QQ客服
淘宝官网