自动重定向到https? [英] automatic redirection to https?

查看:210
本文介绍了自动重定向到https?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用:

< meta http-equiv =REFRESHcontent =0; url = https:// www在html代码中的.the-domain-you-want-to-redirect-to.com / index.html>



它会无休止地循环和刷新https页面。



我如何将用户重定向到https? [关于一个index.html文件]



如果我们需要在index.html的html代码中重定向它们,如果它们只使用http



谢谢解决方案

  var loc = window.location.href +''; 
if(loc.indexOf('http://')== 0){
window.location.href = loc.replace('http://','https://') ;
}

也许?只要你不介意一个小的javascript依赖。


if i use:

<meta http-equiv="REFRESH" content="0;url=https://www.the-domain-you-want-to-redirect-to.com/index.html">

in the html code then it will endlessly loop and refresh the https page.

How can i redirect the users to https? [regarding one index.html file]

What do i need to put in the html code of that "index.html" to redirect them, if they use only "http"?

Thanks

解决方案

var loc = window.location.href+'';
if (loc.indexOf('http://')==0){
    window.location.href = loc.replace('http://','https://');
}

maybe? as long as you don't mind a small javascript dependency.

这篇关于自动重定向到https?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆