uber
uber

Reputation: 65

robots.txt: How to disallow all subdirectories but allow parent folder

I'd like to disallow all subdirectories in my folder /search but allow indexing the search folder itself (I have content on /search).

Testing this does not work:

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

Upvotes: 5

Views: 1437

Answers (1)

Michael Benjamin
Michael Benjamin

Reputation: 371163

Your code appears correct. Try with a slight adjustment to Allow:

User-Agent: *
Disallow: /search/*
Allow: /search/$

Upvotes: 5

Related Questions