wss1051 发表于 2016-12-26 08:14:18

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;
页: [1]
查看完整版本: Nginx Rewrite 去掉重定向的参数