<span id="Label3"></p><p><p>http://zyan.cc/post/142/</p></p><p><p>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 " <span style="color: blue;"> "between http and HTTPS</span> " article, so had to write the PHP implementation of HTTP and HTTPS conversion Code.<br>If the Web page uses HTTPS access, add the following code at the beginning of the Page:</p></p>View plainprint? <ol class="dp-c" start="1"> <ol class="dp-c" start="1"> <li class="alt"><?php</li> <li><span class="comment">HTTP conversion to HTTPS</span></li> <li class="alt"><span class="keyword">if (<span class="vars">$_server[<span class="string">"HTTPS"]<><span class="string">"on")</span> </span> </span></span></li> <li>{</li> <li class="alt"><span class="vars">$xredir =<span class="string">"https://". <span class="vars"> $_server[<span class="string">"server_name"]. </span></span></span></span></li> <li><span class="vars">$_server[<span class="string">"request_uri"]; </span></span></li> <li class="alt">Header (<span class="string">"location:". <span class="vars">) $xredir); </span></span></li> <li>}</li> <li class="alt">?></li> </ol> </ol><p><p><br>If the Web page uses HTTP access, add the following code at the beginning of the Page:</p></p>View plainprint? <ol class="dp-c" start="1"> <ol class="dp-c" start="1"> <ol class="dp-c" start="1"> <li class="alt"><?php</li> <li><span class="comment">HTTPS conversion to HTTP</span></li> <li class="alt"><span class="keyword">if (<span class="vars">$_server[<span class="string">"HTTPS"]==<span class="string">"on")</span> </span> </span></span></li> <li>{</li> <li class="alt"><span class="vars">$xredir =<span class="string">"http://". <span class="vars"> $_server[<span class="string">"server_name"]. </span></span></span></span></li> <li><span class="vars">$_server[<span class="string">"request_uri"]; </span></span></li> <li class="alt">Header (<span class="string">"location:". <span class="vars">) $xredir); </span></span></li> <li>}</li> <li class="alt">?></li> </ol> </ol> </ol><p><p>PHP for HTTP and HTTPS conversions</p></p></span>
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