PHP for HTTP and HTTPS conversion _php tutorial

Source: Internet
Author: User
Recently in the PHP program, you need to make the browser between HTTPS and HTTP conversion, Internet search related information, but only recently in the PHP program, need to make the browser between HTTPS and HTTP conversion, Internet search related information, but only one introduction with ASP implementation " "Between HTTP and https" article, so had to write the PHP implementation of HTTP and HTTPS conversion code.

If the Web page uses HTTPS access, add the following code at the beginning of the page:

View Plainprint?

HTTP conversion to HTTPS

if ($_server["HTTPS"]<> "on")

{

$xredir = "https://". $_server["SERVER_NAME"].

$_server["Request_uri"];

Header ("Location:". $xredir);

}

?>

If the Web page uses HTTP access, add the following code at the beginning of the page:

View Plainprint?

HTTPS conversion to HTTP

if ($_server["HTTPS"]== "on")

{

$xredir = "http://". $_server["SERVER_NAME"].

$_server["Request_uri"];

Header ("Location:". $xredir);

}

?>

http://www.bkjia.com/PHPjc/478700.html www.bkjia.com true http://www.bkjia.com/PHPjc/478700.html techarticle recently in the PHP program, you need to make the browser between HTTPS and HTTP conversion, Internet search related information, but only recently in writing PHP program, need to make the browser between HTTPS and HTTP ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.