请选择 进入手机版 | 继续访问电脑版

叶子网络bbs论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 11809|回复: 0

跳转到https代码

[复制链接]

47

主题

110

帖子

1565

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1565
发表于 2018-4-18 16:49:02 | 显示全部楼层 |阅读模式
//方法一 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>


回复

使用道具 举报

手机版|Archiver|叶子官网|杭州轩翼网络科技有限公司 ( 浙ICP备17027999号

GMT+8, 2024-3-29 05:56 , Processed in 0.275727 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表