thinkphp 配置ssl 強(qiáng)制https訪問時(shí) 如何去掉index.php后輟?
阿里云IIS7.5環(huán)境下 配置好了http 重寫向https
可是輸入http://www.xxx.com 后 會(huì)重定向到https://www.xxx.com/index.php/
如何去掉這個(gè)index.php???
我的實(shí)現(xiàn)方法
不用配置iis url重寫模塊
直接在thinkphp 入口文件寫入以下代碼即可 (iis證書需要配置)
if ($_SERVER['HTTPS'] != "on") {
$index = strstr($_SERVER['REQUEST_URI'],"index.php");
if($index){
$str = preg_replace('/\/index.php/', '', $_SERVER['REQUEST_URI']);
$url = "https://" . $_SERVER["SERVER_NAME"] . $str;
header("location:".$url);
}
}