nginx rewrite for an url with parameters
Ok, thanks to the initial help of rzab, I have redefined his rule to this working solution:
location / {
if ($args ~* "/?param1=val1¶m2=¶m3=[0-9]+¶m4=.+¶m5=[0-9]+") {
rewrite ^ http://www.example.com/newparam/$arg_param3/$arg_param4? last;
}
}
I just added a condition to avoid infinite recursion, and a ? at the end of the rule to get rid of the initial params. It works perfectly :)
location = / { rewrite ^ http://www.example.com/newparam/$arg_param3/$arg_param4; }