How to remove the query string in a RewriteRule

By November 5, 2013 No Comments

Sometimes you are trying to redirect a url to using Apache mod_rewrite.

The easiest method we have found is to add the ? at the end of your RewriteRule destination URL

For Example:

[pure_message style=”modern-info” icon=”#”]
RewriteCond %{QUERY_STRING} ^id=5$
 RewriteRule ^/$ /somepage? [R=301, L]

Thats pretty much it, the new destination URL will be free of the query string.

A cool online .htaccess testing tools we found helpful and think might help others figure out what is working and more importantly what is not working when creating an htaccess rule. Give i a try here

The .htaccess testing does not work for all rules but it really is handy.

Robert Rooke

Author Robert Rooke

More posts by Robert Rooke

Leave a Reply