centOS7.4 thinkPHP nginx 支持pathinfo和rewrite

server
{
    listen 80;
    server_name  www.demo.com  mayifanx.com;
    root  /data/www/demo;
    index index.php index.html index.htm;

    #红色部分支持rewrite
    location / {
          if (!-e $request_filename){
              rewrite ^(.*)$ /index.php?s=$1 last;
          }
    }

    location ~ \.php {
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;

          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

          #蓝色部分是支持pathinfo
          fastcgi_split_path_info ^(.+\.php)(.*)$;
          fastcgi_param PATH_INFO $fastcgi_path_info;

          include        fastcgi_params;

    }
}

猜你喜欢

转载自www.cnblogs.com/yuzhould/p/9161633.html