有人通过添加一个问号和随机字符,按以下格式在我的网站上随机的网页创建错误的链接:
Someone is creating erroneous links by adding a question mark and random characters to random pages on my website in the following format:
www.mydomain.com/ ?57237933 (只有数字) www.mydomain.com/folder1/ ?709d0c24941 (字母) www.mydomain.com/folder1/page-name/ ?20?9h572 (双问号) www.mydomain.com/?57237933 (only numbers) www.mydomain.com/folder1/?709d0c24941 (with letters) www.mydomain.com/folder1/page-name/?20?9h572 (double question mark)我已经找到了robots.txt的阻止规则,但需要一个更强大的htaccess的解决方案。我要寻找一个htaccess的重写规则,可以删除?
和一切从任何网址其后,重定向访问者到原来的URL。
I have found a block rule for robots.txt but need a stronger htaccess solution. I am looking for a htaccess rewrite rule that can remove the ?
and everything following it from any URLs, redirecting the visitor to the original URL.
我找到了解决方案,以消除,例如,?ID = 123
但是当 ID =
ISN牛逼那里,我还没有找到一个解决方案。
I've found solutions to remove, for example, ?id=123
but when id=
isn't there I haven't found a solution.
推荐答案
以下两条规则检查查询字符串的presence并重定向到页面的无查询字符串的版本:
The following two rules check for the presence of query string and redirect to the no-query string version of the page:
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^(.*) /$1? [R,L]
既然你担心搜索引擎抓取错误版本的页面,可以考虑改为 R = 301
一旦你进行测试。此外,你可能要考虑返回404错误阻碍使用的查询字符串,告诉搜索引擎,有没有这样的事情 http://mydomain.com/page/?1234
。
Since you are worried about search engines crawling wrong version of page, consider changing to R=301
once you've tested. Also, you might want to consider returning a 404 error to discourage the use of query strings and tell the search engines that there is no such thing as http://mydomain.com/page/?1234
.
相关推荐
最新文章