location ^~ modifier
Francis Daly
francis at daoine.org
Wed Dec 9 08:47:05 UTC 2015
On Tue, Dec 08, 2015 at 06:33:52PM +0100, B.R. wrote:
Hi there,
> That means the following is a 'prefix' location block:
> location /whatever/ {
> }
>
> That said, this block will match the /whatever/ string anywhere in the URI
> string, not only at its start.
No, it won't.
===
location / {
return 200 "in location /\n";
}
location /aaa/ {
return 200 "in location /aaa/\n";
}
===
$ curl http://localhost/aaa/bbb/
in location /aaa/
$ curl http://localhost/bbb/aaa/
in location /
> As a consequence, to me, the meaning of 'prefix' was not tied to the
> location of the matched string in the URI, but rather a definition more
> like 'matching a string in the URI'.
No.
"prefix" has its normal English language meaning. The documentation at
http://nginx.org/r/location is correct.
(I think the documentation there is *incomplete*, as it is not immediately
clear to me how nested locations are searched. But that has been clarified
on the mailing list recently, and that clarification matches what can
be seen in tests.)
> Where is the exit of the maze again?
prefix matches -- without modifier, with modifier ^~, and (technically,
probably) with modifier = -- are exact string matches at the start of
the url. (And consequently should all start with the character "/".)
If you want to match something that is not an exact string match at the
start of the url, you must use something that is not a prefix match.
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list