2008年4月27日星期日

php 在http和https之间转化

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

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

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


* if ($_SERVER["HTTPS"]=="on")
* { $xredir="http://".$_SERVER["SERVER_NAME"].
* $_SERVER["REQUEST_URI"]; header("Location: ".$xredir);
* }
* ?>

没有评论: