本文轉自: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); } ?>