htaccess 301 obsolete query string to homepage

2019-09-08 02:54发布

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?

1条回答
够拽才男人
2楼-- · 2019-09-08 03:33

How about:

RewriteCond %{QUERY_STRING} ^_pu= [NC]
RewriteRule ^(?:index.php|)$ /? [L,R=301,NC]
查看更多
登录 后发表回答