iis-ssl certificate - thinkphp configures ssl to force https access. How to remove the index.php suffix?
我想大声告诉你
我想大声告诉你 2017-05-16 13:09:33
0
2
938

How to remove the index.php suffix when configuring SSL in thinkphp to force https access?

In Alibaba Cloud IIS7.5 environment, http is configured to rewrite to https

But after entering http://www.xxx.com, it will be redirected to https://www.xxx.com/index.php/

How to remove this index.php???

我想大声告诉你
我想大声告诉你

reply all(2)
左手右手慢动作

index.php is the entry file of thinkphp

phpcn_u1582

My implementation method

No need to configure iis url rewriting module

Write the following code directly into the thinkphp entry file (iis certificate needs to be configured)

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);
        }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template