4

I would like to allow a path and disallow everything else in the directory.

User-Agent: *
Allow: /example/
Disallow: /example/*

Will this work? If not what would be a better way of doing this?

1 Answer 1

4

I actually found this helpful.

https://moz.com/community/q/robots-txt-how-to-exclude-sub-directories-correctly

User-Agent: *
allow: /example/$
disallow: /example/*
2
  • 3
    The "$" matches the end of a URL for anyone curious. More info: developers.google.com/search/reference/robots_txt Commented Apr 2, 2019 at 19:00
  • 3
    Worth pointing out that the rule set only works with user agents that support both the Allow directive and regular expressions. Googlebot will obey that properly, and probably Bingbot. Not many other user agents will though. Commented Apr 2, 2019 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.