最近发现一个问题,在tp5框架中,在域名后面必须加index.php才可以正常访问,不然就会报错

thinkphp5访问路径中省略index.php方法

thinkphp5访问路径中省略index.php方法

 

就像上图这样,只有添加上index.php才能正常访问

解决方法:我使用的是Nginx,所以就就改了一下conf文件:

location / {
    if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=/$1  last;
    }
}

在location / {  }中添加上这段代码后,重启nginx服务就可以了。

thinkphp5访问路径中省略index.php方法

 

如果使用宝塔面板,就非常方便了,在网站的编辑中,在<伪静态>一项中添加上,重启服务就可以了。

thinkphp5访问路径中省略index.php方法

 

如果使用的是Apache或者IIS,也有解决办法,可以参考:http://www.thinkphp.cn/topic/63996.html

 

相关文章:

  • 2022-12-23
  • 2021-09-12
  • 2021-09-14
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
相关资源
相似解决方案