location ^~ modifier

Francis Daly francis at daoine.org
Tue Dec 8 08:40:48 UTC 2015

On Mon, Dec 07, 2015 at 10:08:40PM +0100, B.R. wrote:

Hi there,

> Does the ^~ location modifier finds a matching string at the start of an
> URI?


> I naively thought it was just a variant of the classic prefix search,


> without any constraint on the placement of the matched string in an URI.


> Is there a simple way of matching the longest prefix location anywhere in
> an URI, discarding any regex location at the same level?

"prefix" means "at the start".

I'm not sure what you're asking.

The first regex location that matches is used (with caveats). So if you
have a regex location which is just your desired string, that is first in
the config file, then it will be used ahead of any other regex locations
that might have been used.

Francis Daly        francis at daoine.org

More information about the nginx mailing list