Quantcast
Channel: 看得透又看得远者prevail.ppt.cc/flUmLx ppt.cc/fqtgqx ppt.cc/fZsXUx ppt.cc/fhWnZx ppt.cc/fnrkVx ppt.cc/f2CBVx
Viewing all articles
Browse latest Browse all 20480

php设置强制使用https访问

$
0
0
出于安全等考虑,可能需要设置强制https访问,那么php中可以采取如下设置。
代码如下:


if($_SERVER["HTTPS"]<>"on")
{
$xredir="https://".$_SERVER["SERVER_NAME"].
$_SERVER["REQUEST_URI"];header("Location: ".$xredir);
 
}
如果要强制非https访问那么把<>改成==就可以了。
https访问需要响应的ssl证书,默认的不可信任倒是也没关系,如果需要可信任的证书,可搜索
nginx-https-ssl-module的相关教程。

Viewing all articles
Browse latest Browse all 20480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>