问题描述
譬如我要重写以下路由:/user?id=55/question到/dispatch这个地方,要怎么写呢?
问题解答
回答1:location /question/ { rewrite ^/question(.*) /dispatch$1 last;}location /user/ { if ($query_string = 'id=55') {rewrite ^/user(.*) /dispatch$1 last; } }回答2:
location /question/ {
rewrite ^/question(.*) /dispatch$1 last;
}
location /user/ {
if ($query_string = 'id=55') { rewrite ^/user(.*) /dispatch$1 last;}
}