叶子网络bbs论坛
标题:
跳转到https代码
[打印本页]
作者:
admin
时间:
2018-4-18 16:49
标题:
跳转到https代码
//方法一 https状态
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off'){
Header("HTTP/1.1 301 Moved Permanently");
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}
//方法二 判断端口
if($_SERVER['SERVER_PORT']=="80"){
Header("HTTP/1.1 301 Moved Permanently");
header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}注:以上两个方法,加到根目录每个文件中,替换。
方法三:
在linux系统中,选用IIs文件,在web.config文件中加:
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
欢迎光临 叶子网络bbs论坛 (http://xuanfly.com/)
Powered by Discuz! X3.3