Welcome! Log In Create A New Profile

Advanced

Re: Debugging `try_files` with 404 as a last resort

November 13, 2018 08:30PM
Francis Daly Wrote:
-------------------------------------------------------

> Do you know whether the file that corresponds to the url /index.php
> exists?
>
> If it does exist, use
>
> try_files $uri $uri/ /index.php?$args;
>
> If it does not exist, use
>
> try_files $uri $uri/ =404;

Hello Francis. Thank you for your reply.

I have some servers where the `index.php` exists, and some where it does not exist. I have been using the approach you outlined above successfully where I know `index.php` exists (or not), 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.

> 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?

Thanks again, I am grateful for your time and assistance.
Subject Author Posted

Debugging `try_files` with 404 as a last resort

petecooper November 13, 2018 05:23PM

Re: Debugging `try_files` with 404 as a last resort

Francis Daly November 13, 2018 06:32PM

Re: Debugging `try_files` with 404 as a last resort

petecooper November 13, 2018 08:30PM

Re: Debugging `try_files` with 404 as a last resort

Francis Daly November 14, 2018 03:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 186
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready