Recently, when writing a PHP program, you need to convert the browser between https and http and search for relevant information online. However, when writing a PHP program recently, to enable the browser to convert between https and http and search for relevant information on the Internet, there is only one article about ASP implementation between http and https... syntaxHighlighter. all
Recently, when writing a PHP program, you need to convert the browser between https and http and search for relevant information online. However, when writing a PHP program recently, to enable the browser to convert between https and http and search for relevant information on the Internet, there is only one article about how to use ASP to implement "conversion between http and https, so I had to write the code for converting http and https using PHP.
If the webpage is accessed over https, add the following code at the beginning of the webpage:
View plainprint?
// Convert http to https
If ($ _ SERVER ["HTTPS"] <> "on ")
{
$ Xredir = "https: //". $ _ SERVER ["SERVER_NAME"].
$ _ SERVER ["REQUEST_URI"];
Header ("Location:". $ xredir );
}
?>
If the webpage is accessed through http, add the following code at the beginning of the webpage:
View plainprint?
// Convert https to http
If ($ _ SERVER ["HTTPS"] = "on ")
{
$ Xredir = "http: //". $ _ SERVER ["SERVER_NAME"].
$ _ SERVER ["REQUEST_URI"];
Header ("Location:". $ xredir );
}
?>