Home > Backend Development > PHP Tutorial > Determine whether it is HTTPS and jump

Determine whether it is HTTPS and jump

WBOY
Release: 2016-07-25 09:01:17
Original
1816 people have browsed it
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
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template