我在添加 sitemap.xml
时在我的 Google 网站站长工具中遇到了这个错误
URL restricted by robots.txt
在我的 robots.txt 中我有:
User-agent: *
Allow: /$
Disallow: /
它只是为了索引我的主页而不是所有网站。
最佳答案
为什么那里有 $
。为什么 Disallow:/
:
User-agent: *
Allow: /$
Disallow: /
只需将其更改为:
User-agent: *
Allow: /
但是如果你只想让它索引实际的索引页,那么就把它改成这样:
User-agent: *
Allow: /index.php
Disallow: /
或者也许这样做会改变指令的顺序:
User-agent: *
Disallow: /
Allow: /index.php
Allow: /$
最后一个示例结合了您的 robots.txt
项目,但也对它们进行了重新排序。所以它应该像你想要的那样工作;只有索引页,没有别的。
关于php - 谷歌的 Robots.txt 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23945655/