让nginx 支持PATH_INFO

很多PHP框架默认使用PHP的PATH_INFO 来进行URL重写
当用Nginx作为http服务器的时候,就出现问题了,愿意是Nginx为定义PATH_INFO这个变量,我们想要使用PHP框架的PATH_INFO重写时候,必须定义这个变量

代码比较简单
 location ~ \.php($|/) {
		root	   /www/test;

		set $script     $uri;
		set $path_info  "";

		if ($uri ~ "^(.+?\.php)(/.*)$") {
		    set $script     $1;
		    set $path_info  $2;
		}

		fastcgi_index	index.php;
		fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param   PATH_INFO       $path_info;
		fastcgi_pass    unix:/tmp/php-fpm.sock;
		include	fastcgi_params;
    	}



这样PHP框架就可以使用PATH_INFO 重写了

你可能感兴趣的:(PHP,框架,nginx,unix,Flash)