ThinkPHP运行环境Apache转Nginx配置如下

分类首页日期4年前访问3239评论0

只需要添加这行代码:

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

具体代码如下:

server {
    listen 80;
    server_name **.com;
    root "C:/wwwroot/**/public";
    location / {
        index index.html index.htm index.php default.php;
        //重点就是加入下面这个if
        if (!-e $request_filename){
          rewrite  ^(.*)$  /index.php?s=$1  last;   break;
        }
    }
    location ~ .php(.*)$ {
        fastcgi_pass 127.0.0.1:18158;
        fastcgi_index index.html;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
    }
}