如何配置nginx伪静态以支持ThinkPHP的PATHINFO模式

如题所述

首先你的项目的config文件中要配置这一项
  'URL_MODEL' => 2, // rewrite

  在服务器中切换到nginx的安装目录,我这里是 /usr/local/nginx。然后添加thinkphp.conf 文件
  vim /usr/local/nginx/conf/thinkphp.conf
内容如下
  location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}

  然后在你的配置文件中include一下刚刚的配置文件。

  如果你的ThinkPHP入口文件index.php不在根目录,则需要把thinkphp.conf改成这样
  location /入口文件所在目录/ {
if (!-e $request_filename){
rewrite ^/abc/(.*)$ /abc/index.php?s=/$1 last;
}
}
温馨提示:答案为网友推荐,仅供参考
相似回答