How to disallow nested folders with robots.txt?

by ervin.williamson , in category: SEO , 4 months ago

How to disallow nested folders with robots.txt?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by rusty.rosenbaum , 4 months ago

@ervin.williamson 

To disallow nested folders with robots.txt, you can use a wildcard (*) to block any URLs containing slashes (/). Here's an example:


User-agent: * Disallow: /*/


This rule will block any URLs that have a slash (/) in them, effectively disallowing nested folders. For instance, it will disallow URLs like /folder1/subfolder1/ or /folder2/subfolder2/. However, it will still allow URLs without slashes such as /folder1 and /folder2.