码迷,mamicode.com
首页 > Web开发 > 详细

PHP实现http与https转化

时间:2017-11-03 19:06:16      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:tps   head   使用   div   $_server   server   pre   实现   ade   

本文转自:http://zyan.cc/post/142/

1、如果网页使用https访问,在网页开头加入以下代码:

<?php    
//http转化为https     
if ($_SERVER["HTTPS"]<>"on")    
{    
$xredir="https://".$_SERVER["SERVER_NAME"].    
$_SERVER["REQUEST_URI"];    
header("Location: ".$xredir);    
}     
?>    

2、如果网页使用http访问,在网页开头加入以下代码:

<?php    
//https转化为http     
if ($_SERVER["HTTPS"]=="on")    
{    
$xredir="http://".$_SERVER["SERVER_NAME"].    
$_SERVER["REQUEST_URI"];    
header("Location: ".$xredir);    
}     
?>

  

PHP实现http与https转化

标签:tps   head   使用   div   $_server   server   pre   实现   ade   

原文地址:http://www.cnblogs.com/bluealine/p/7779410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!