判断是否为HTTPS并跳转
时间:2021-07-01 10:21:17
帮助过:84人阅读
在PHP运行开始时,检验是否位HTTPS链接,若不是则跳转
- switch (TRUE) {
- case (!isset($_SERVER['HTTPS'])) :
- case ($_SERVER['HTTPS']!="on") :
- RedirectToHttps();
- break;
- }
- function RedirectToHttps(){
- $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
- header("Location:$redirect");
- exit;
- }
|