今日份服务器调整

于 2019-05-19 发布

之前忘了调强制301 https跳转,今天想起来想要做,但是发现了新的做法:在index.php里添加跳转代码,而不是在nginx的conf文件里添加,可以节省资源:

1
if(!((isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']=='on')||(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])&&$_SERVER['HTTP_X_FORWARDED_PROTO']=='https'))){ Header("HTTP/1.1 301 Moved Permanently"); header('Location: https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']); }

参考:CSDN - PHP代码http跳转到https

目录