首页域名资讯 正文

使用程序强制跳转到HTTPS – HTTPS SSL 教程

2025-01-13 1 0条评论

 

兼容:

<!-- 如果检测到是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;
}

 

文章版权及转载声明

本文作者:亿网 网址:https://edns.com/ask/post/150002.html 发布于 2025-01-13
文章转载或复制请以超链接形式并注明出处。