本文介绍了htaccess 301过时的查询字符串到主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要重定向(从URL中完全删除)我使用的旧查询字符串,但是现在我的网站已经废弃了.
I need to redirect (remove completely from URL) the old query string i used but which is now obsolete for my site.
所以我需要
http://example.com/?_pu=true
使用户重定向到
http://example.com/
我只需要301重定向即可将其从URL中删除,因此用户将不会共享该URL.问题是查询字符串(?),我认为因为我的这段代码不起作用:
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
我也尝试过:
RewriteCond %{QUERY_STRING} ^pu=(.+)$ [NC]
RewriteRule ^index.php$ /? [L,R=301,NC]
但这也不起作用.
有什么想法吗?
推荐答案
怎么样:
RewriteCond %{QUERY_STRING} ^_pu= [NC]
RewriteRule ^(?:index.php|)$ /? [L,R=301,NC]
这篇关于htaccess 301过时的查询字符串到主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!