Remove query string on rewrite

Maxim Dounin mdounin at mdounin.ru
Thu Aug 12 14:00:53 MSD 2010


Hello!

On Thu, Aug 12, 2010 at 02:32:56AM -0400, celevra wrote:

> Hi,
> I am trying to make a 301 redirect like this: 
> /authors.php?name=xxx  ==> /author/xxx
> 
> this config solves the problem partially - 
> 
>         location ~ ^/authors.php {
>                  if ($args ~ "name=(.+)" ) {
>                            set $arg_name $1;
>                           rewrite ^/authors\.php "/author/$arg_name"
> permanent;
>                 }
>         }
> 
> But the query string remains, and the final location is
> /author/xxx?name=xxx
> 
> How can i remove the unneeded query string? 

Add trailing "?" to replacement string.

http://wiki.nginx.org/NginxHttpRewriteModule#rewrite

Maxim Dounin



More information about the nginx mailing list