【问题标题】:robots.txt blocking crawlers from accesing page [closed]robots.txt 阻止爬虫访问页面[关闭]
【发布时间】:2014-02-01 13:50:54
【问题描述】:

我试图找到如何阻止爬虫访问我的链接,如下所示:

site.com/something-search.html

我想屏蔽所有的 /something-*

有人可以帮我吗?

【问题讨论】:

  • 这个问题似乎是题外话,因为它是关于 SEO

标签: seo web-crawler robots.txt


【解决方案1】:
User-agent: *
Disallow: /something-

这会阻止路径以 /something- 开头的所有 URL,例如可从 http://example.com/robots.txt 访问的 robots.txt:

  • http://example.com/something-
  • http://example.com/something-foo
  • http://example.com/something-foo.html
  • http://example.com/something-foo/bar

仍允许使用以下 URL:

  • http://example.com/something
  • http://example.com/something.html
  • http://example.com/something/

【讨论】:

    【解决方案2】:

    在您的 robots.txt 中

    User-agent: *
    Disallow: site.com/something-(1st link)
    .
    .
    .
    Disallow: site.com/somedthing-(last link)
    

    为您不想被看到的每个页面添加条目!

    虽然 robots.txt 中不允许使用正则表达式,但一些智能爬虫可以理解它!

    看看here

    【讨论】:

    • 问题是我不知道第一个和最后一个链接是什么,这是我的搜索结果页面,我想禁用爬虫访问该搜索页面......我试过这个:不允许: /search-* 此处不允许使用通配符(如“*”) 下面的行必须是允许、禁止、注释或空行语句
    • 不,你不能在 robots.txt 中使用 *
    • Disallow 不得包含 URL 的主机(在您的情况下为 site.com)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 1970-01-01
    • 2016-01-25
    • 2012-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多