nginx location match rule, without matching trailing characters
There are two ways to handle this, use a regular expression location
block - or just handle /foo
separately from /foo/
.
Regular expression location
blocks have a different evaluation order and are less efficient than prefix location
blocks, so my preferred solution is the exact match location
and prefix location
.
Generally, /foo
just redirects to /foo/
, for example:
location = /foo { return 302 /foo/; }location /foo/ { ...}
See this document for more.
You can create one Location rule to /foobar whether you need it as an exception:
location = /foobar { .... }
Nginx match first URI by = operator.