とほほのrobots.txt入門

目次

robots.txtとは

robots.txtのサンプル

robots.txt のサンプルを示します。

# Example of robots.txt
User-agent: RedBot
User-agent: BlueBot*
Disallow: /
Allow: /index.html
Allow: /usage.html

User-agent: *
Disallow: /temporary/
Disallow: /old/

Sitemap: https://example.com/sitemap.xml

詳細

robots.txt の配置場所

OK https://example.com/robots.txt
NG https://example.com/some_dir/robots.txt

ファイルの書き方

コメント(#)

# for Google Bot and Bing Bot
User-agent: Googlebot
User-agent: bingbot

ユーザーエージェント(User-agent)

User-agent: Googlebot
User-agent: OrangeBot
Disallow: /temporary/

禁止(Disallow)

User-agent: Googlebot
Disallow: /temporary/
Disallow: /old/
Disallow: /*.txt$
Disallow: /foo?url=https%3A%2F%2Ffoo.bar    # /foo?url=https://foo.baa
Disallow: /foo-%24                          # /foo-$

許可(Allow)

User-agent: RedBot
Disallow: /
Allow: /index.html
Allow: /usage.html

サイトマップ(Sitemap)

Sitemap: https://example.com/sitemap.xml

よくみかけるボット(クローラー)

下記などのボットをよく見かけます。