(各种版本) http怎么做自动跳转https
APache、Nginx、IIS、Tomcat等各种服务器版本设置http自动跳转到https的方法大全较适合指定某一个子页单独https在需要强制为https的页面上加入以下代码进行处理http-->https<script type="text/javascript"> var url = window.location.href; if (url.indexOf("https") < 0) { url = url.replace("http:", "https:"); window.location.replace(url); }</script>
2、在需要强制为http的页面上加入以下代码进行处理https-->http<script language="JavaScript" type="text/JavaScript">function redirect(){ var loc = location.href.split(':');if(loc=='https') { location.href='http:'+loc; }} onload=redirect</script>7
PHP页面跳转
1、添加在网站php页面内if ($_SERVER["HTTPS"] <> "on") { $xredir="https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; header("Location: ".$xredir); }