robots.txt 文件应该如何为子域正确编写?
How robots.txt file should be properly written for subdomains?
有人可以解释一下如果我希望所有爬虫都索引根目录和一些特定的子域,我应该如何编写 robots.txt 文件
User-agent: *
Allow: /
Allow: /subdomain1/
Allow: /subdomain2/
这样对吗?我应该把它放在哪里?在根 (public_html) 文件夹中还是在每个子域文件夹中?
无法在单个 robots.txt 文件中为不同的子域指定规则。给定的 robots.txt 文件将仅控制对其发出请求的子域的抓取。如果您想阻止某些子域并允许其他子域,那么您需要提供来自不同子域的不同 robots.txt 文件。
例如,如果您要允许抓取 http://crawlme.example.com/, but you want to block crawling of http://nocrawl.example.com/,则:
http://crawlme.example.com/robots.txt 应包含:
# Allow everything:
User-agent: *
Disallow:
和http://nocrawl.example.com/robots.txt应该包含:
# Block everything:
User-agent: *
Disallow: /
有人可以解释一下如果我希望所有爬虫都索引根目录和一些特定的子域,我应该如何编写 robots.txt 文件
User-agent: *
Allow: /
Allow: /subdomain1/
Allow: /subdomain2/
这样对吗?我应该把它放在哪里?在根 (public_html) 文件夹中还是在每个子域文件夹中?
无法在单个 robots.txt 文件中为不同的子域指定规则。给定的 robots.txt 文件将仅控制对其发出请求的子域的抓取。如果您想阻止某些子域并允许其他子域,那么您需要提供来自不同子域的不同 robots.txt 文件。
例如,如果您要允许抓取 http://crawlme.example.com/, but you want to block crawling of http://nocrawl.example.com/,则:
http://crawlme.example.com/robots.txt 应包含:
# Allow everything:
User-agent: *
Disallow:
和http://nocrawl.example.com/robots.txt应该包含:
# Block everything:
User-agent: *
Disallow: /