Block robots from folder and sub folders

I think I’ve got this right, but need to check…

folder structure is like this…

level1 > sub 1
level1 > sub 2
level1 > sub3

If I want to stop all folders contained within > sub1 do I add a robots.txt file to > level1 with the following in it?

User-agent: *
Disallow: sub1/*

Or, do I put that robots.txt file in > level1 > sub1 ?


The robots.txt file must be at the root level of the website.

Format and location rules:

  • The file must be named robots.txt
  • Your site can have only one robots.txt file.
  • The robots.txt file must be located at the root of the website host that it applies to. For instance, to control crawling on all URLs below , the robots.txt file must be located at . It cannot be placed in a subdirectory ( for example, at ). If you’re unsure about how to access your website root, or need permissions to do so, contact your web hosting service provider. If you can’t access your website root, use an alternative blocking method such as meta tags.
  • A robots.txt file can apply to subdomains (for example, ) or on non-standard ports (for example, ).
  • Comments are any lines that start with a # mark.

They (google) have an excellent tester:

1 Like

Thanks Teefers. I completely missed that!