Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#1649 closed enhancement (worksforme)

Improve documentation for the location block

Reported by: ovidiu.b13@… Owned by:
Priority: minor Milestone:
Component: documentation Version:
Keywords: Cc:
uname -a: N/A
nginx -V: N/A


The documentation for the location block does not clearly state the order in which matching is done for non-prefixed locations.


location / {...}
location /foo {...}

If I go to "/foo", are all the location blocks checked, and the longest match selected? Or is the written order taken into consideration?

The documentation currently only talks about prefixed locations or regular expressions, and provides no clarification for non-prefixed locations.

Change History (2)

comment:1 Changed 7 months ago by pluknet

  • Resolution set to worksforme
  • Status changed from new to closed

There are no "non-prefixed" locations. Please consult with the documentation.
Here are some snippets for your convenience:

A location can either be defined by a prefix string, or by a regular expression.

To find location matching a given request, nginx first checks locations defined
using the prefix strings (prefix locations). Among them, the location with the
longest matching prefix is selected and remembered.

In general, a better place to ask user questions about nginx is the nginx@ mailing list.

comment:2 Changed 7 months ago by ovidiu.b13@…

I assumed that "prefix" means

[ = | ~ | ~* | ^~ ]

And by non-prefixed I meant if I don't use any of those.

If I understand you correctly, I need to read from somewhere: what's the definition of a prefixed string?

Is it defined somewhere else? if not, this term should be clarified.

Last edited 7 months ago by ovidiu.b13@… (previous) (diff)
Note: See TracTickets for help on using tickets.