NGINX: strip querystring in rewrite

Posted by Roger on Server Fault See other posts from Server Fault or by Roger
Published on 2011-10-19T17:59:44Z Indexed on 2012/10/17 5:09 UTC
Read the original article Hit count: 519

Filed under:
|
|

I'd like to make a 301 rewrite to the sites's index without any querystring. Like this:

http://example.com/anypage.asp?anyvar=anyvalue

To:

http://example.com/

Here's a real example:

http://atipico.com.br/conteudo.asp?P_categ=23

I am trying to follow this: http://wiki.nginx.org/NginxHttpRewriteModule#rewrite

(The commented are my attempts):

location ~ /conteudo\.asp(.*)$ {
    #rewrite ^ / permanent;
    #rewrite ^ /? permanent;
    #return 301 /;
    #return 301 /?;
    #if ($args) { return 301 /; }
}

It always rewrites to http://atipico.com.br/?P_categ=23

Any ideas?

© Server Fault or respective owner

Related posts about nginx

Related posts about 301-redirect