I'm trying to achieve some URL rewrite rules in nginx. I use similar regex to capture the interesting groups, it works perfectly in regex101, and in IIS rewrite rules' regex, but not working in nginx map. I don't know exactly if there is a specific syntax for nginx or not, I couldn't find out.
map $request_uri $new_uri {
default '';
# this works without the query string part
#"~^/r/([\S]+)\.jpg$" http://www.jackli.space/$1.jpg;
"~^/r/([\S]+).(png|jpg|jpeg)\?a=(\d+)$" http://www.jackli.space/$1.$2?x=$3;
}
Sample image src url I test with
<img src="r/images/bridge.jpg?a=100" />