nginx仅使用查询字符串的值重写

时间:2014-11-18 16:23:52

标签: nginx rewrite

我想从

重定向
   www.setup.com/view.php?id=213

 www.setup.com/213

这是我的nginx重定向

  location ^~ view.php  {
    if ($query_string ~ "^id=([0-9-]+)$"){
    rewrite ^/view.php$ http://$server_name/%1? break;
    }
  }

由于某种原因,它附加

  ?id= to the url

所以它变成了

www.setup.com?id=213

如何删除

   ?id= from the url?

1 个答案:

答案 0 :(得分:0)

使用:

location / {
    rewrite ^/view.php$ /$arg_id? redirect; 
}