Reputation: 573
I need to rewrite URL with querystring:
http://www.example.com/?p=121&cpage=7
to:
What's the easiest way to do it on .htaccess?
Upvotes: 0
Views: 40
Reputation: 4917
You can achieve that using:
RewriteEngine On
RewriteCond %{QUERY_STRING} p=(.+)$
RewriteRule ^(.*)$ http://www.example.com? [R=301,L]
The {QUERY_STRING} will detect the correct query, and if the condition is met it will rewrite it to www.example.com
.
The ?
at the end of the redirected URL is there so that the query string does not appear on the end of the URL.
Make sure you clear your cache before testing this.
Upvotes: 1