I am using this rewrite in NGINX. rewrite ^/test[^a-zA-Z0-9]{2}/?$ https://www.google.com permanent; // doesn't work
The server fails to start with I add the min {2}
repetition in the regex. The server comes up when I remove that like here: rewrite ^/test[^a-zA-Z0-9]/?$ https://www.google.com permanent; // this works
I have tried both {min,max}
params.
The error that I get when I use the min
repetition is as below. directive "rewrite" is not terminated by ";"
The context of this rewrite is server
.
Can someone tell if what am I missing? Is there some module that need to be installed for this to work?
My prod NGINX version is 1.4 and I tried it on my local with 1.10.
This is by design -- curly brackets are special in nginx.conf, if used as a part of a regular expression, then you have to use double quotes around your regular expression if you're using the braces.
http://nginx.org/r/rewrite
If a regular expression includes the “}” or “;” characters, the whole expressions should be enclosed in single or double quotes.
E.g.,
rewrite "^/test[^a-zA-Z0-9]{2}/?$" https://www.google.com/ permanent;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With