htaccess的删除查询字符串 [英] htaccess remove query string
问题描述
我不是太熟悉规则前pressions和我有麻烦达到我想要的。
I'm not too familiar with regular expressions and I'm having trouble achieving what I want.
我正在使用的网站上有一个字preSS博客,也有在互联网上指向的 http://www.website.com/?p=(随机数)。
The website I'm working on used to have a wordpress blog on it and there are existing links on the internet pointing to http://www.website.com/?p=(random number).
目前的code我现在似乎不工作:
The current code I have right now doesn't seem to work:
RewriteCond %{QUERY_STRING} p=(.*)
RewriteRule http://www.website.com/ [R=301,L]
事实上,如果有一种方法,以消除任何形式的索引页的查询字符串,这将是更好的。
In fact if there is a way to remove any kind of query string for the index page, that would be even better.
在此先感谢。
推荐答案
如果您要删除所有的查询字符串,无论
If you want to remove all query strings regardless
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [R,L]
此测试,如果有任何查询字符串。
,然后重定向到主页上没有查询字符串 / <?/ code>
This tests if there is any query string .
and then redirects to the home page without query string /?
.
永远不要的测试与 301
启用,看到这个答案
提示调试的.htaccess重写规则的
了解详细信息。
Never test with 301
enabled, see this answer
Tips for debugging .htaccess rewrite rules
for details.
这篇关于htaccess的删除查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!