记录一下,安装好tp6后,不需要手动改写nginx的配置文件nginx.conf,只需要在phpstudy中创建网站后,点击“管理”->“修改”。
然后,进入伪静态,输入以下代码,确定保存,即可自动配置好nginx.conf。
重启nginx后,可实现伪静态(去掉入口index.php)和原生(包含入口index.php)地址的双有效访问。
具体代码段如下:
if (!-e $request_filename){
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^/(.*)$ /index.php?s=$1 last;
}