+ -
当前位置:首页 → 问答吧 → 让nginx 支持PATH_INFO

让nginx 支持PATH_INFO

时间:2011-04-14

来源:互联网

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

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

  3.                 set $script     $uri;
  4.                 set $path_info  "";

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

  9.                 fastcgi_index        index.php;
  10.                 fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  11.                 fastcgi_param   PATH_INFO       $path_info;
  12.                 fastcgi_pass    unix:/tmp/php-fpm.sock;
  13.                 include        fastcgi_params;
  14.             }
复制代码
这样PHP框架就可以使用PATH_INFO 重写了

作者: so_brave   发布时间: 2011-04-14

鄙人不用框架,所以不存在这个问题。

作者: maochanglu   发布时间: 2011-04-14

热门下载

更多