试着去 http://example.com/shop/donate?id=123 重定向到 http://example.com/donate/123
在我的.conf中使用以下内容,点击顶部网址不会导致重定向。 .conf中的其他重定向正在运行。有什么想法吗?
server{
....
rewrite ^/shop/donate?id=([0-9]+)$ /donate/$1 permanent;
}
答案 0 :(得分:0)
在这种情况下,您可以尝试使用$ arg_ [name]:
rewrite ^/shop/donate$ /donate/$arg_id;
答案 1 :(得分:-1)
你需要转义问号,否则它会被解析为正则表达式:
server{
....
rewrite ^/shop/donate\?id=([0-9]+)$ /donate/$1 permanent;
}