【问题标题】:"Disallow: /test/programmming" or "Disallow: /programming"?“禁止:/test/programming”还是“禁止:/programming”?
【发布时间】:2019-03-06 14:57:10
【问题描述】:

我在 WordPress 下管理一个网站。我们不得不将站点 URL 更改为 example.com/test。因此,我现在在 Search Console 中有 2 个属性:一个具有根域 (example.com)。另一个带有子目录(example.com/test)。

每当我在 Google 中搜索 site:example.com 时,它都会返回所有可索引的 URL,即主页的 example.com/test。因此,域根 example.com 不再可索引。

在 robots.txt 中,我喜欢禁止某些 URL,例如 example.com/test/programming

我应该禁止:/programming 还是禁止:/test/programmming 以使 example.com/test/programming 被阻止?

【问题讨论】:

  • 如果您阻止此 URL,您是否希望其他页面被编入索引?或者您是否希望文档example.com/test/programming 根本不被抓取,无论在哪个 URL 下?
  • 我希望这个网址根本不被抓取(example.com/test/programming),这样您就知道我的网站网址是 example.com/test 而不是根域

标签: robots.txt


【解决方案1】:

Disallow 值始终表示 URL 路径的开头。

对于https://example.com/test/programming,路径为/test/programming

所以,Disallow: /test/programming 会阻止这样的 URL:

  • https://example.com/test/programming
  • https://example.com/test/programming/
  • https://example.com/test/programming.html
  • https://example.com/test/programming/foo/bar

Disallow: /programming 会阻止这样的 URL:

  • https://example.com/programming
  • https://example.com/programming/
  • https://example.com/programming.html
  • https://example.com/programming/foo/bar

【讨论】:

  • /问题是我的网站是一个 wordpress 我使用 example.com/test 作为我的主页我的站点地图是 example.com/test/siteamp.xml 而我的机器人文件在 example.com/ robots.txt 我只想知道机器人在 / 之前读取了哪个 url
  • @emma:我不明白你为什么认为这是个问题。在这种情况下,站点地图 URL 无关紧要,您的 robots.txt 位于正确的位置。机器人抓取它可以找到链接到某处的 URL。如果您使用/链接带有 /test/ 的 URL,这就是机器人将访问的内容。
猜你喜欢
  • 2013-06-03
  • 2010-09-13
  • 2010-10-10
  • 1970-01-01
  • 2021-06-01
  • 1970-01-01
  • 2011-03-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多