Reputation: 2859
It sounds like a relatively simple one but here goes.. I have a wordpress website called example.com It has recently been redeveloped using wordpress however the old sites structure used the following www.example.com/?page_id=22 I want to redirect anything after the domain name that contains /?page_id=[any digit] to the homepage, im having great difficulty in accomplishing this and I also think I may have issues because wordpress itself uses the query string page_id before the permalinks redirects kick in, I could be wrong though but any help on removing the query string directly after a domain name would be great especially keeping in mind that it is a wordpress install.
I have tried various iterations that look like the following to no avail
RewriteCond %{QUERY_STRING} ^page_id=(.*)$
RewriteRule (.*) http://www.example.com/ [R=301,L]
RedirectMatch 301 ^/page_id=(.*)$ /
Upvotes: 2
Views: 333
Reputation: 784988
Try this rule right at top, just below RewriteEngine On
line:
RewriteCond %{QUERY_STRING} ^page_id=\d+$ [NC]
RewriteRule ^/?$ /? [R=301,L]
/?
will strip off any query string.
Upvotes: 2