4

I need to exclude anything that contains /page/ but only at root:

Disallowed: example.com/page/1

Allowed: example.com/category/page/1

How to safely write this in robots.txt?

5

You almost have it.

This is the correct syntax:

User-agent: *
Disallow: /page

Explanation:

The Disallow: directive is relative-to-root.

So the very first / in that directive indicates the root folder of your website.

Consequently, the directive Disallow: /page will disallow:

/page/alpha/
/page/beta/
/page/gamma/

but it won't disallow:

/aleph/page/
/bet/page/
/gimel/page/

because the latter three paths don't begin with /page/.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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