How to stop htaccess rewrite rule carrying over query string

Posted by geoffs3310 on Stack Overflow See other posts from Stack Overflow or by geoffs3310
Published on 2012-04-12T11:21:58Z Indexed on 2012/04/12 11:29 UTC
Read the original article Hit count: 307

I am setting up some redirects. I want to redirect the following URL:

/cms/index.php?cat_id=2

to the following URL:

/flash-chromatography

The rule I currently have is as follows:

RewriteCond %{QUERY_STRING} ^cat_id=2$ [NC]
RewriteRule ^cms/index\.php$ /flash-chromatography [L,R=301]

This rule is almost perfect apart from it redirect the URL to the following:

/flash-chromatography?cat_id=2

So you see my problem is it has kept the ?cat_id=2 part when I don't want it to.

How do I stop it keeping this bit?

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about mod-rewrite