root and alias with php5-fpm

Francis Daly francis at
Tue Sep 8 07:44:49 UTC 2015

On Mon, Sep 07, 2015 at 06:48:57PM -0500, Kristofer Pettijohn wrote:

Hi there,

> > I suggest using a named location for handling the "not there" fallback
> > -- either as the final argument to try_files, or perhaps as "error_page
> > 404 = @fallback".
> > 
> > Then
> > 
> >  location @fallback {
> >    fastcgi_param SCRIPT_FILENAME /apps/grant/index.php;
> >    include fastcgi_params;
> >    fastcgi_pass unix:/local/sockets/grant.sock;
> >  }
> > 
> That is what I am attempting to do with my try_files directive:
> try_files $uri $uri/ /grant/index.php?$args;
> If the file does not exist, I want it to try “index.php” in the root of the grant folder, so in the try_files directive I have “/grant/index.php?$args” so that it tries using the proper location.  At least that’s how I understand try_files?

No - the last argument to try_files is different to the other arguments.

If this last argument is used, you get an internal redirect to the url
/grant/index.php?$args, and the appropriate location{} to handle that
request is chosen from scratch.

Which shows exactly what you see, which is not what you want.

Does "try_files $uri $uri/ @fallback;" do what you want?

(Rename @fallback to @grant or @grantindex if you like.)

Francis Daly        francis at

More information about the nginx mailing list