Welcome! Log In Create A New Profile

Advanced

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

Francis Daly
November 13, 2018 06:32PM
On Tue, Nov 13, 2018 at 05:23:41PM -0500, petecooper wrote:

Hi there,

> Ideally, I would like the following route for `try_files` (in order):
>
> * $uri (requested URI)
> * $uri/ (requested URI, trailing slash)
> * /index.php?$args (use root `index.php` with args)
> * =404 (Nginx returns 404)

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;

But really, in the latter case, you are probably better off just omitting
the try_files line altogether.

> I do not fully understand why https://example.com/articles results in a 404
> Not Found when `index.php?$args` generates a valid page (200 OK) and
> precedes `=404`. Does the `=` carry some weight?
>
> I would greatly appreciate a pointer for further reading so I can better
> understand.

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.

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.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
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: 256
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