0

Will disallowing certain folder in robots.txt disallow its related subfolders? Example:

Disallow:/folder/

Will match:

/folder/page
/folder/subfolder/page

Or it will just match:

/folder/page

So if the second case is true, do I need to disallow second and subsequent subfolder separately?

Disallow: /folder/

Disallow  /folder/subfolder/

Disallow /folder/subfolder/onemorefolder
Vasyl Nekohda
  • 171
  • 1
  • 1
  • 7

1 Answers1

0

Robots.txt has no concept of "folders", it’s just strings. Whatever you specify in Disallow is the beginning of the URL path.

Disallow: / blocks any URL whose path starts with / (= all pages).

Disallow: /foo blocks any URL whose path starts with /foo:

  • /foo
  • /foobar
  • /foo.html
  • /foo/bar
  • /foo/bar/doe

Disallow: /foo/ blocks any URL whose path starts with /foo/:

  • /foo/
  • /foo/bar.html
  • /foo/bar
  • /foo/bar/doe
unor
  • 92,415
  • 26
  • 211
  • 360
  • Very good explanation. Thanks! I believe the same concept is used in bunch of other similar things, like gitignore file for example. I wonder what other special characters are allowed when making you rules, except asterisk. – Vasyl Nekohda Sep 16 '15 at 12:32
  • @vaseech: The original robots.txt specification doesn’t define *any* special characters with reserved meanings for `Disallow` values. So if you have `Disallow: /foo*`, the `*` is interpreted literally, i.e., URLs that contain the asterisk. However, specific consumers (like the Googlebot) often extend the robots.txt specification and interpret certain characters differently. – unor Sep 17 '15 at 14:54