第一种方式是通过重写url来实现pathinfo模式:
1 location / { 2 if (!-e $request_filename){ 3 rewrite ^/(.*)$ /index.php?s=/$1 last; 4 } 5 }
第二种方式 ,改变 \.php的
1 location ~ \.php { 2 #fastcgi_pass 127.0.0.1:9000; 3 #fastcgi_pass unix:/dev/shm/php-cgi.sock; 4 fastcgi_pass unix:/tmp/php-cgi.sock; 5 fastcgi_index index.php; 6 include fastcgi.conf; 7 set $real_script_name $fastcgi_script_name; 8 if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { 9 set $real_script_name $1; 10 set $path_info $2; 11 } 12 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; 13 fastcgi_param SCRIPT_NAME $real_script_name; 14 fastcgi_param PATH_INFO $path_info; 15 }
第二种方案没测试通过