Debugging `try_files` with 404 as a last resort
francis at daoine.org
Wed Nov 14 08:22:17 UTC 2018
On Tue, Nov 13, 2018 at 08:30:08PM -0500, petecooper wrote:
> Francis Daly Wrote:
> I think my question could perhaps be
> worded: is there a `try_files` option where I can have $uri, then $uri/,
> then `index.php` and finally `=404` if all else fails.
I believe "not directly".
You possibly could have try_files falling back to a uri which is handled
in a location which in turn does try_files?
> > http://nginx.org/r/try_files
> > The final argument to try_files is a uri or =code. "code" is
> > returned. "uri" is searched for across all locations (due to an
> > internal
> > redirect).
> > The other arguments to try_files are files.
> This is how I understood it, thank you for confirming!
> > Does a file with the name $document_root/index.php?$args (expanding
> > the
> > two variables) exist? If not, processing will continue until the uri
> > or
> > =code at the end of the argument list.
> I know the file `index.php` exists in the `root`. Would using the two
> expanded variables in a log be sufficient to confirm Nginx can see it, or am
> I missing something?
If $args is empty, then your config asks nginx to serve the file
`index.php?`, which is not the same as the file `index.php`.
Basically, try_files is for trying files, and gives one non-file
fallback. You seem to want more than one non-file fallback.
Maybe you can built something close to what you want using error_page?
Good luck with it,
Francis Daly francis at daoine.org
More information about the nginx