PHP实现http与https转化
2015-09-19 23:57
609 查看
本文转自:http://zyan.cc/post/142/
1、如果网页使用https访问,在网页开头加入以下代码:
2、如果网页使用http访问,在网页开头加入以下代码:
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); } ?>
相关文章推荐
- 网络编程入门(1
- HTTP转HTTPS实现
- 2015沈阳网络赛 1002(HDU 5451 矩阵快速幂 + 矩阵循环群)
- 利用ASIHttpRequest框架进行网络数据请求(二)—— 利用post发送表单请求数据
- HttpClient请求返回JSON、图片
- Largest Point(2015年吉林网络赛)
- C# HttpUtility.UrlEncode 与 JAVA URLEncoder.encode 区别
- 2015沈阳网络赛总结
- http的header参数有关
- 网络协议之HTTP协议
- Jesus Is Here(2015年吉林网络赛)
- wamp Could not execute menu item和 HTTP Error 404. The requested resource is not found.
- httpd虚拟主机,压缩机制,https实现,压力测试
- Minimum Cut(2015年吉林网络赛)
- java线程join的意思(转自http://zjj1211.blog_51cto_com)
- POST和GET登陆
- 世界各国网络域名后缀
- JSP报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- 2015长春、沈阳网络赛总结
- 2015长春、沈阳网络赛总结