Reputation: 4128
i need simple Nginx rewrite rule to rewrite
/?contidion1=variable1&condition2=variable2
to
/variable1/variable2/
This one doesn't work...
rewrite ^/condition/(.*)/([0-9])$ /?condition1=$1&condition2=$2 last;
Also tried:
rewrite ^/condition/(.*)/(.*)$ /?condition1=$1&condition2=$2 last;
However condition with 1 variable working good
rewrite ^/condition/(.*)$ /?condition1=$1 last;
Upvotes: 0
Views: 3607
Reputation: 3863
You can use something like this or exactly this:
rewrite ^/\?condition1=([^&]*)&condition2=([^&]*) /$1/$2 last;
First rule in rewrite
means what pattern your url must pass to be rewrited to secondrewrite
rule. Next in second rule you can use parameter as $1
and $2
which correspondents to group in first rule (group is delimited by (
and )
)
If doing in other way, because your suggestion what you want to do are a little different from your rewrite rules, do something like this:
rewrite /(.*)/(.*) /?condition1=$1&condition2=$2 last;
Upvotes: 2