当前位置: 代码迷 >> Web前端 >> Nginx Rewrite 除去重定向的参数
  详细解决方案

Nginx Rewrite 除去重定向的参数

热度:738   发布时间:2013-09-30 09:50:49.0
Nginx Rewrite 去掉重定向的参数

http://example.com/test.php?para=xxx?重定向到?http://example.com/new

若按照默认的写法:rewrite ^/test.php(.*) /new permanent;

重定向后的结果是:http://example.com/new?para=xxx

如果改写成:rewrite ^/test.php(.*) /new? permanent;

?

那结果就是:http://example.com/new

?

http://wiki.nginx.org/HttpRewriteModule

?

If in the line of replacement arguments are indicated, then the rest of the request arguments are appended to them. To avoid having them appended, place a question mark as the last character:

?

  rewrite  ^/users/(.*)$  /show?user=$1?  last;