Welcome! Log In Create A New Profile

Advanced

Re: Understanding location blocks and try files

Francis Daly
January 22, 2014 03:38PM
On Wed, Jan 22, 2014 at 02:54:35PM -0500, AD7six wrote:

Hi there,

> location ~ \.php$ {
> location ~* \.(?:manifest|appcache|html?|xml|json)$ {

> A valid response where the url is a file:
>
> $ curl -i http://nginx.dev/foo.json
> HTTP/1.1 200 OK

> An invalid response when passed to php:
>
> $ curl -i http://nginx.dev/apples.json
> HTTP/1.1 404 Not Found

Why do you think that this request is passed to php?

> Am I missing something obvious or falling for a common misunderstanding?

One request is handled in one location.

The request "/apples.json" is handled in the second location above. Which
says (by omission of any other directive) "serve it from the file system
or return 404".

The error_page for 404 is also handled in that location, and the
appropriate file is found and returned.

> Is there a way to define location blocks for static files - without that
> causing problems for dynamic requests for the same url pattern?

"location" matches the uri. "static file" or "dynamic request" is
irrelevant at that point.

So "no"; but also "probably", depending on what exactly you want to do.

(The general suggestion in nginx is to use prefix-match locations at
the top level, not regex-match ones.)

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Understanding location blocks and try files

AD7six January 22, 2014 01:31PM

Re: Understanding location blocks and try files

Jonathan Matthews January 22, 2014 02:04PM

Re: Understanding location blocks and try files

AD7six January 22, 2014 02:54PM

Re: Understanding location blocks and try files

Francis Daly January 22, 2014 03:38PM

Re: Understanding location blocks and try files

Jonathan Matthews January 22, 2014 04:08PM

Re: Understanding location blocks and try files

Valentin V. Bartenev January 22, 2014 04:32PM

Re: Understanding location blocks and try files

Francis Daly January 22, 2014 05:20PM

Re: Understanding location blocks and try files

AD7six January 23, 2014 06:54AM

Re: Understanding location blocks and try files

Francis Daly January 23, 2014 08:44PM

Re: Understanding location blocks and try files

AD7six January 24, 2014 11:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 161
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