日度归档:2012年4月20日

nginx配置PATH_INFO并rewrite掉中间的index.php

最近看博客统计数据,还是有很多搜索nginx 配置 PATH_INFO 和去掉中间的index.php的关键词,所以把目前自己在用的配置传一份到网上

server
{
listen 80;
server_name ye55.dev;
index index.html index.htm index.php default.html default.htm default.php;
root /home/www/ye55/trunk/www/;

if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
location ~ .*\.php(.*)$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}