首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >js http 强制跳转到 https 全站重定向

js http 强制跳转到 https 全站重定向

作者头像
Savalone
发布2020-02-11 13:12:37
发布2020-02-11 13:12:37
4.7K0
举报
文章被收录于专栏:Savalone's BlogSavalone's Blog
代码语言:javascript
复制
<script type="text/javascript">
var targetProtocol = "https:";
if (window.location.protocol != targetProtocol)
 window.location.href = targetProtocol +
  window.location.href.substring(window.location.protocol.length);
</script>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019年08月02日,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档