I don't know if this question is allowed or not. If not, forgive me :)
Anyway, I have a mapping rule for nginx redirection
/hotel/xyz/abc /hotel/xyz/abc-nana;
/hotel/xyz/abc/ /hotel/xyz/abc-nana;
~^/hotel/xyz/abc\?(.*) /hotel/xyz/abc-nana?$1;
My question is, can they be combined into 1 rule? I don't know regex well
I assume
xyz
andabc
mean any alphanumeric string. Then you are looking for a rule like this:(0-9a-z]+)
matches any alphanumeric string having one or more matches. The results are stored into$1
and$2
variables. The last slash match is optional (?
specifies 0 or 1 matches).In nginx, one cannot match the query arguments in
location
orrewrite
statements. However, if you only want to add possible query arguments without modification to the redirect, then$is_args$args
is enough for that.