PHP: How can I get domain.com/index.php/blah/ to work?

Igor Sysoev is at rambler-co.ru
Tue Jul 24 12:41:16 MSD 2007


On Tue, Jul 24, 2007 at 03:17:15AM +0000, Rob wrote:

> > > Igor Sysoev <is <at> ...> writes:
> > > 
> > > > 
> > > > Do you use FastCGI ?
> > > > 
> > > > .. snip ..
> 
> Hi Igor. Everything works correctly, but I'd like to use the AUTH module to
> restrict access to /layouts/submit/admin or /graphics/submit/admin. Of course,
> these really would go to /index.php/layouts/submit/admin, and
> /index.php/graphics/submit/admin. Here's my config: http://pastie.caboo.se/81634
> 
> For some reason after I do the above and visit domain.com/layouts/submit/admin
> and enter my user/pass, I get a 404 instead of it rewriting it to
> /index.php/layouts/submit/admin. Can you help?

This is because "location ~ /(layouts|graphics)/submit/admin" has static
handler. You should use the following:

  location ~ /(layouts|graphics)/submit/admin {
    auth_basic "Restricted";
    auth_basic_user_file domains/htpasswd;

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

    if ($uri ~ ^(.+\.php)(/.+)$) {
      set $path_info $2;
      set $script_name $1;
    }

    include fastcgi.conf;
    fastcgi_pass 127.0.0.1:5000;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$script_name;
  }

  location ~ \.php(/|$) {
    set $path_info "";
    set $script_name $uri;

    if ($uri ~ ^(.+\.php)(/.+)$) {
      set $path_info $2;
      set $script_name $1;
    }

    include fastcgi.conf;
    fastcgi_pass 127.0.0.1:5000;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$script_name;
  }


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





More information about the nginx mailing list