htaccess 301 obsolete query string to homepage

安稳与你 提交于 2019-12-13 07:42:52

问题


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:


How about:

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


来源:https://stackoverflow.com/questions/29225914/htaccess-301-obsolete-query-string-to-homepage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!