John
John

Reputation: 387

htaccess 301 redirect querystring to root

I'm stuck trying to redirect my old posts on my wordpress blog from www.domain.com/?p=444 to just the root, this is because the posts have been removed.

This is what i have tried so far.

RewriteCond %{QUERY_STRING} p=[0-9]+
RewriteRule ^p$ / [L,R=301]

Any help would be much aprreciated.

Best Regards

Upvotes: 1

Views: 518

Answers (1)

anubhava
anubhava

Reputation: 785481

Use this rule:

RewriteEngine On

RewriteCond %{QUERY_STRING} p=[0-9]+ [NC]
RewriteRule ^$ /? [L,R=301]

/? means root URL with ? for removing existing query string removed.

Upvotes: 1

Related Questions