Rewrite with number after hyphen

Ivan Bianchi ivan at wikiloc.com
Mon Sep 3 06:13:11 UTC 2018


Hi,

I detected an issue with my rewrite rule in the nginx.conf and I don't
understand why it happens and how to fix it.

I have tested in two environments with versions 1.10.3 and 1.14.0.

Having the following simple conf with a regex is intended to get everything:

> location /foo {
> rewrite /foo/(.*) /web/foo.do?a=$1 last;
> }


OK:

> https://www.test.com/foo/asdf

https://www.test.com/foo/asdf-asdf

https://www.test.com/foo/asdf12

https://www.test.com/foo/asdf12-asdf

https://www.test.com/foo/12

https://www.test.com/foo/-12


KO:

> https://www.test.com/foo/asdf-12

https://www.test.com/foo/asdf-12-asdf


As implementing pcre regex, this regex works in all cases in the common
regex online sites but not in nginx.

Why if I put a number after a hyphen the regex stops working?

Many thanks,

-- 
Ivan Bianchi
Wikiloc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180903/110ba725/attachment.html>


More information about the nginx mailing list