Home  >  Article  >  Backend Development  >  Determine whether it is HTTPS and jump

Determine whether it is HTTPS and jump

WBOY
WBOYOriginal
2016-07-25 09:01:171752browse
At the beginning of PHP running, check whether it is an HTTPS link, if not, jump                  
                                                                                                                                                                                                                                                                                                    



switch (TRUE) {
case (!isset($_SERVER['HTTPS'])) :
case ($_SERVER['HTTPS']!="on") :
    RedirectToHttps();
  1. break;
  2. }
  3. Copy code
                                                                                                                                                                                                                                                                                     
function RedirectToHttps(){
$redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header("Location:$redirect");
exit;
}
  1. Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn