关于nginx的pathinfo问题
在我刚接触到服务器的时候,这个nginx的问题困扰了我很久,在多方求证和请教后,对于正则切割还是半知半解,最后也不是很能理解他的代码运作原理。只是有效的运作了,所以把代码贴在这后面再回来看:
location ~ .+\.php($|/) {
33 set $script $uri;
34 set $path_info "";
35 if ($uri ~ "^(.+\.php)(/.+)") {
36 set $script $1;
37 set $path_info $2;
38 }
39 fastcgi_pass 127.0.0.1:9000;
40 fastcgi_index index.php?IF_REWRITE=1;
41 fastcgi_param PATH_INFO $path_info;
42 fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
43 fastcgi_param SCRIPT_NAME $script;
44 include fastcgi_params;
45 }
46
47 location ~ /\.ht {
48 deny all;
49 }
50