Best way to get the $request_uri without the starting slash
Igor Sysoev
igor at sysoev.ru
Tue Dec 20 09:45:21 UTC 2011
On Tue, Dec 20, 2011 at 04:36:49AM -0500, WheresWardy wrote:
> Thanks, that's exactly what I was looking for.
>
> The $1 didn't work however, nginx complained about it being an
> unreferenced variable, so I modified it to look like the examples in the
> documentation (maybe you can't reference pattern matches numerically
> like elsewhere in the config?):
>
> map $request_uri $request_key {
> default index;
> ~^/(?P<key>.+)$ $key;
> }
Yes, numeric references are not supported in map.
You can also change default to empty string:
map $request_uri $request_key {
default "";
~^/(?P<key>.+)$ $key;
}
--
Igor Sysoev
More information about the nginx
mailing list