nginx try_file和fastcgi_split_path_info

看到火丁的博客里的一篇文章,try_file和fastcgi_split_path_info的问题想了好久,一通googlephp

问题的描述在这里,为何会用这种问题呢;最后仍是在鸟哥的博客里看到了。html

try_files有一个本身专门的工做阶段,并且它还会重置$fastcgi_script_name 和 $fastcgi_path_infonginx

The ​try_files directive changes URI of a request to the one matched on the file system, and subsequent attempt to split the URI into $fastcgi_script_name and $fastcgi_path_info results in empty path info - as there is no path info in the URI after try_files.google

根据这个推测fastcgi_split_path_info应该是工做在try_files阶段以前的,被后来的try_files指令覆盖了,具体是工做在那个阶段,暂时没查到。unix

那这个问题怎么解决呢,就是新加一个变量保存下$fastcgi_path_info的值htm

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Save the $fastcgi_path_info before try_files clear it
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}blog

相关文章
相关标签/搜索