欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Nginx Rewrite 去掉重定向的参数 博客分类: nginx nginxrewrite

程序员文章站 2024-02-28 22:53:40
...

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;
相关标签: nginx rewrite