今天配置了下codeigniter在nginx服务器的rewrite,主要有2点: 1、非静态文件和允许访问的php脚本外的请求转到index.php location / { index index.php; root /path/to/your/ci/directory; # 重写到index if ($request_filename !~ (js|css|images|robots/.txt|index/.php.*) ) { rewrite ^/(.*)$ /index.php/$1 last; break; } } 2、给nginx的fastcgi加上pathinfo参数 location ~ /index.php/ { fastcgi_param SCRIPT_FILENAME /path/to/your/index.php; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; # 你也可以写到fastcgi_params文件中 fastcgi_param PATH_INFO $fastcgi_script_name; }