【问题标题】:How do I disallow specific page from robots.txt如何禁止 robots.txt 中的特定页面
【发布时间】:2010-08-15 06:29:50
【问题描述】:

我正在我的网站上创建两个非常相似但用途不同的页面。一是感谢用户发表评论,二是鼓励用户订阅。

我不想要重复的内容,但我确实希望页面可用。我可以将站点地图设置为隐藏吗?我会在 robots.txt 文件中执行此操作吗?

禁止看起来像这样:

禁止:/wp-admin

我将如何自定义特定页面,例如:

http://sweatingthebigstuff.com/thank-you-for-commenting

【问题讨论】:

    标签: robots.txt


    【解决方案1】:
    Disallow: /thank-you-for-commenting
    

    robots.txt

    查看last.fm robots.txt file 以获得灵感。

    【讨论】:

    • 我很欣慰有人有远见,不允许对人类造成伤害。
    • 这肯定会出现误报,因为标准规定“不会检索以该值开头的任何 URL”。
    【解决方案2】:

    robots.txt 文件使用正则表达式来匹配页面,因此为避免定位的页面超出您的预期,您可能需要在页面名称的末尾添加 $:

    Disallow: /thank-you-for-commenting$
    

    如果你不这样做,你也会禁止页面 /thank-you-for-commenting-on-this-too

    【讨论】:

      【解决方案3】:

      您还可以在 robots.txt 文件中添加带有扩展名的特定页面。在测试的情况下,您可以指定测试页面路径以禁止机器人抓取。

      例如:

       Disallow: /index_test.php
       Disallow: /products/test_product.html
       Disallow: /products/     
      

      第一个Disallow: /index_test.php 将禁止机器人爬取根文件夹中的测试页面。

      第二个Disallow: /products/test_product.html 将禁止“产品”文件夹下的 test_product.html。

      最后一个示例Disallow: /products/ 将禁止整个文件夹抓取。

      【讨论】:

        【解决方案4】:

        这很简单,任何你想禁止的页面,只要给出这个文件或文件夹的根 url。 只需将其放入您的 robots.txt 文件中即可。

        Disallow: /thank-you-for-commenting
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多