Reputation: 3
I'm not too familiar with regular expressions and I'm having trouble achieving what I want.
The website I'm working on used to have a wordpress blog on it and there are existing links on the internet pointing to http://www.website.com/?p=(random number).
The current code I have right now doesn't seem to work:
RewriteCond %{QUERY_STRING} p=(.*)
RewriteRule http://www.website.com/ [R=301,L]
In fact if there is a way to remove any kind of query string for the index page, that would be even better.
Thanks in advance.
Upvotes: 0
Views: 5817
Reputation: 74018
If you want to remove all query strings regardless
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [R,L]
This tests if there is any query string .
and then redirects to the home page without query string /?
.
Never test with 301
enabled, see this answer
Tips for debugging .htaccess rewrite rules
for details.
Upvotes: 3