解决Chrome强制把http成功定向为https的问题
说明
http重定向为https本来是一个好的方案,毕竟https更安全,但是有的情况下我们真的只需要http访问。这时候Chrome默认的重定向就会导致问题。
比如我的博客,图床用的是http协议访问,但是Chrome重定向了之后就会导致所有的图片都访问不了,因此我们还是需要访问http的。
chrome浏览器解决
现在已经无法保证能生效了,偶尔能生效
1 | > HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that is specified by a web application through the use of a special response header. Once a supported browser receives this header that browser will prevent any communications from being sent over HTTP to the specified domain and will instead send all communications over HTTPS. |
查阅相关资料,发现这是浏览器的HSTS(HTTP Strict Transport Security)功能引起的。在安装配置SSL证书时,可以使用一种能使数据传输更加安全的Web安全协议,即在服务器端上开启HSTS ,它会告诉浏览器只能通过HTTPS访问,而绝对禁止HTTP方式。
因此,只要关闭浏览器的HSTS功能就可以解决这个问题,但是只能通过特定的方式,而不是清除浏览器缓存那么简单。
chrome
- 地址栏中输入
chrome://net-internals/#hsts
。 - 在Delete domain中输入项目的域名,并Delete(删除)。
- 可以在Query domain测试是否删除成功。
- 地址栏中输入
edeg
与chrome一致,地址edge://net-internals/#hsts
现在已经证实只是概率性的解决了,真烦。。。。。。
还是看看Nginx配置解决吧
nginx 配置解决
如果你服务端使用的是nginx,那么可以配置Nginx的重定向,将https重定向成http,也可以解决
使用Nginx的**return 301 http://blog.liukewen.cn$request_uri
**,采用301 或 302重定向都可以
1 | server { |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 KewenBlogs!
评论