php一句代码让http跳转https

时间:2020-01-03 09:59:00   收藏:0   阅读:101
//其他框架请加到入口某共公加载的文件中
//方法一 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‘]);
}

原文:https://www.cnblogs.com/trip-j/p/php.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!