Problems with fastcgi php migration

Igor Sysoev is at rambler-co.ru
Wed Mar 12 10:38:14 MSK 2008


On Tue, Mar 11, 2008 at 06:17:50PM -0400, Ian M. Evans wrote:

> Igor Sysoev wrote:
> >- location ~ ^/(galleries|poll|news)/ {
> >+ location ~ ^/(galleries|poll|news)(/|$) {
> >
> >because otherwise nginx handles /galleries, etc. as local files.
> >
> >Then probably you need to set PATH_INFO:
> >
> >   location ~ ^/(galleries|poll|news)(/|$) {
> >       set  $path_info  "";
> >       if ($uri ~ ^/[^/]+(/.+)) {
> >           set  $path_info  $1;
> >       }
> >
> >       fastcgi_pass ...
> >       fastcgi_param  PATH_INFO $path_info;
> >       ...
> >   }
> >
> 
> The results:
> 
> Firefox:
> Calling /galleries pulls up page. Adding further info (e.g. /30/1/1) 
> pulls up photo page as expected.
> 
> Calling /galleries/ (with trailing slash) still pulls up a 404 error.
> 
> IE7:
> /galleries creates same passing result as Firefox.
> /galleries/, like Firefox calls up the 404 page.
> 
> So we're much, much closer...only stumbling block is getting it to run 
> properly if a visitor adds a trailing slash. Is that just a matter of 
> forcing no trailing slash if there's nothing else following it?

Then you try to remove cgi.fix-pathinfo and to use the following:

   location ~ ^/(galleries|poll|news)(/|$) {

       set  $script_name  $uri;
       set  $path_info    "";

       if ($uri ~ ^(/[^/]+)(/.*)) {
           set  $script_name  $uri;
           set  $path_info    $1;
       }

       fastcgi_pass ...
       fastcgi_param  SCRIPT_FILENAME  $document_root$script_name;
       fastcgi_param  PATH_INFO        $path_info;
       ...
   }

Then you should get the following:

  URL                     SCRIPT_FILENAME               PATH_INFO

/galleries             $document_root/galleries            -
/galleries/            $document_root/galleries            /
/galleries/30/1/1      $document_root/galleries            /30/1/1


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list