北京 天津 河北 山西 内蒙古 辽宁 吉林 黑龙江 上海 江苏 浙江 安徽 福建 江西 山东 河南 湖北 湖南 广东 广西 海南 重庆 四川 贵州 云南 西藏 陕西 甘肃 青海 宁夏 新疆 台湾 香港 澳门
▼分网点

使用程序强制跳转到HTTPS

兼容:

<!-- 如果检测到是http页面,则自动跳转到对应的https页面 -->
<script type="text/javascript">
if (document.location.protocol != "https:") { 
        location.href = location.href.replace(/^http:/,"https:");
}
</script>



ASP:

<%
If Request.ServerVariables("SERVER_PORT")=80 Then
Dim strSecureURL
strSecureURL = "https://"
strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
strSecureURL = strSecureURL & Request.ServerVariables("URL")
Response.Redirect strSecureURL
End If
%>

 

PHP:

if(!isset($_SERVER['HTTPS'])||!$_SERVER['HTTPS']){
$url ='https://'. $_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'];
header('Location: '. $url);exit;
}