【问题标题】:Robots.txt: Disallow subdirectory but allow directoryRobots.txt:不允许子目录但允许目录
【发布时间】:2011-03-22 01:04:32
【问题描述】:

我想允许抓取以下文件:

/directory/

但不抓取以下文件:

/directory/subdirectory/

robots.txt 指令是否正确:

User-agent: *
Disallow: /subdirectory/

恐怕如果我不允许 /directory/subdirectory/ 我会禁止抓取 /directory/ 中我不想做的所有文件,所以我在使用时是否正确:

User-agent: *
Disallow: /subdirectory/

【问题讨论】:

    标签: robots.txt


    【解决方案1】:

    你想多了:

    User-agent: *
    Disallow: /directory/subdirectory/
    

    是正确的。

    【讨论】:

    • 用户代理不是:* Disallow: /directory/subdirectory/ 会删除 /directory/ 中的任何文件吗?我仍然想要搜索索引中目录中的文件,而不是子目录 /directory/subdirectory/ 中的文件
    • 不,它为什么要那样做?它不允许子目录,而不是父目录。
    • 嗯...作为我研究的一部分,互联网上的许多人都说不允许 /directory/subdirectory/ 也不允许 /directory/ 中的所有文件,因此有必要这样做:用户代理: * Disallow: /directory/subdirectory/ Allow: /directory/index.html 我只是想找出哪个是正确的?
    • @user,什么资源说的?要么你误解了,要么他们错了。
    【解决方案2】:
    User-agent: *
    Disallow: /directory/subdirectory/
    

    蜘蛛并不傻,它们可以解析路径:)

    【讨论】:

    • 我不明白你在说什么。
    • @user 如果您选择cd /directory/subdirectory/,是否会转到directory?不,重要文件夹是路径中的最后一个文件夹,在本例中为 subdirectory
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-14
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    相关资源
    最近更新 更多