努力思考 + 实践, 眼高手低是不行的. 注册 | 登陆
浏览模式: 标准 | 列表Tag:nginx

Nginx(PHP/FastCGI)的PATH_INFO问题补充

注: 本文是 http://www.laruence.com/2009/11/13/1138.html 的补充.  
仅为解决使用上文配置PATH_INFO后, 当请求的URI为"<script>/"的情况下PATH_INFO为"/index.php"的问题, 使nginx下的PAHT_INFO表现与Apache一致.
 
如: 访问 "http://localhost/p.php/" 输出的PATH_INFO为"/index.php"  
 
    location ~ \.php($|/) {  
        root           D:/WWW/Localhost;  
        fastcgi_pass   127.0.0.1:9000;  
        fastcgi_index  index.php;  
 
        set $script    $uri;  
        set $path_info "";  
        if ($uri ~ "^(.+\.php)(/.*)") {  
            set  $script     $1;  
            set  $path_info  $2;  
        }  
  
        fastcgi_param SCRIPT_FILENAME $document_root$script;  
        fastcgi_param SCRIPT_NAME $script;  
        fastcgi_param PATH_INFO $path_info;  
 
        include        fastcgi_params;  
    }  
 
参考文档: http://wiki.nginx.org/NginxSymfony, 有细微修改

Tags: nginx, fastcgi