如何配置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;
}
}
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网