【问题标题】:Allow folder, but not specific sub-folders允许文件夹,但不允许特定子文件夹
【发布时间】:2019-04-27 16:40:09
【问题描述】:

对于 robots.txt,我们如何允许一个文件夹而不是特定的子文件夹或页面?

例如,我的博客在 /blog 内,但我想禁止 /blog/wp-admin

下面的代码是否适用于我想要实现的目标?

Disallow: /blog/wp-admin
Allow: /blog

【问题讨论】:

    标签: robots.txt


    【解决方案1】:

    使用就够了

    Disallow: /blog/wp-admin
    

    这将禁止所有路径以/blog/wp-admin: 开头的 URL:

    • https://example.com/blog/wp-admin
    • https://example.com/blog/wp-adminfoo
    • https://example.com/blog/wp-admin/
    • https://example.com/blog/wp-admin.php
    • https://example.com/blog/wp-admin/foo/bar

    允许抓取所有其他 URL,包括:

    • https://example.com/blog/wp-admi
    • https://example.com/blog/wp-adm
    • https://example.com/blog/wp-ad
    • https://example.com/blog/wp-a
    • https://example.com/blog/wp-
    • https://example.com/blog/wp
    • https://example.com/blog/w
    • https://example.com/blog/
    • https://example.com/blog
    • https://example.com/blo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-14
      • 2014-04-15
      • 2013-11-27
      • 1970-01-01
      相关资源
      最近更新 更多