apache下path_info是可以直接取到,但nginx下就比较蛋疼了,对于thinkphp或CI来说更是如此,path_info是取不到的,路由不正常所以很多页面都会404,据说用fix_pathinfo的方法会有安全问题,因此让nginx自己解析吧,这是示例~
server {
listen 80;
server_name admin.test.com;
root /Users/ha/www/html/test/admin.test.com/;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/etc/nginx/fastcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
如果只应用于特定host 则不需要修改fastcgi.conf的配置文件,别忘记重新加载nginx配置
nginx -s reload