index.php呢,因为去除index.php可以使得url看上去优雅不少,同时对SEO静态化有一定的好处。本文就主要针对于Nginx的web服务进行配置讲解。本文以一个 后端 ThinkPHP项目 为例,演示一下配置,重写主要使用到rewrite模块。综合配置如下:
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}