Best way to get the $request_uri without the starting slash

WheresWardy nginx-forum at
Tue Dec 20 09:36:49 UTC 2011

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;

Posted at Nginx Forum:,220245,220299#msg-220299

More information about the nginx mailing list