在Nginx的0.7.31版本以前对pathinfo支持的很不好,需要各种设置,比如Thinkphp就配置很复杂,老版本配置可以参考惠新宸的blog《Nginx(PHP/fastcgi)的PATH_INFO问题》
自从0.7.31以后,大家就有福了,我以Thinkphp为例,配置一下nginx来支持去掉index.php和支持pathinfo
#if(!-e $request_filename) { # rewrite ^/(.*)$ /index.php/$1 last; #} #推荐用try_files方式进行重定向,不兼容的话在考虑用上面的方式 try_files $uri $uri/ /index.php$request_uri; location ~ \.php { #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; fastcgi_split_path_info ^(.*\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 参考:http://wiki.nginx.org/HttpFastcgiModule
转载于:https://blog.51cto.com/weijingwu/1342000