Mordor
Mordor

Reputation: 485

htaccess 301 obsolete query string to homepage

I need to redirect (remove completely from URL) the old query string i used but which is now obsolete for my site.

So i need from

http://example.com/?_pu=true 

to get users redirected to

http://example.com/

I need just 301 redirect to remove it from URL so users won't share that URL. Problem is the query string (?) i think cuz I have this code which doesnt work:

Redirect 301 /?_pu=true http://www.example.com

I also tried this:

RewriteCond %{QUERY_STRING} ^pu=(.+)$ [NC]
RewriteRule ^index.php$ /? [L,R=301,NC]

But that doesn't work either.

Any ideas?

Upvotes: 0

Views: 40

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

How about:

RewriteCond %{QUERY_STRING} ^_pu= [NC]
RewriteRule ^(?:index.php|)$ /? [L,R=301,NC]

Upvotes: 1

Related Questions