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?
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?
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.
p will now be ignored (so cpage) and it takes any number variable related to p.