search

Home  >  Q&A  >  body text

iis-ssl certificate - thinkphp configures ssl to force https access. How to remove the index.php suffix?

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???

我想大声告诉你我想大声告诉你2782 days ago941

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 13:11:33

    index.php is the entry file of thinkphp

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:11:33

    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);
            }
    }

    reply
    0
  • Cancelreply