How to Disallow All Except for robots.txt in Your Site Crawling Rules? or Is There a Way to Disallow

18 Replies, 1757 Views

"Best Method to Disallow All Except for robots.txt – Any Suggestions?"

hey guys, quick question—how do i disallow all except for robots.txt for web crawlers?

i wanna block everything BUT that file. tried messing with the robots.txt rules but not sure if i’m doing it right.

something like:
```
User-agent: *
Disallow: /
Allow: /robots.txt
```
...but does this actually work? or is there a better way?

also, do some crawlers just ignore this anyway? kinda frustrating lol.

thanks in advance!
Your robots.txt example is correct for disallow all except for robots.txt! That’s the standard way to do it.

But yeah, some crawlers ignore it (looking at you, sketchy bots).

If you wanna go nuclear, block IPs or use .htaccess/server-side rules. Tools like Cloudflare or Bot Manager can help too.
The syntax you used is spot-on for disallow all except robots.txt. Most legit bots respect it, but bad ones won’t care.

For extra security, maybe add rate limiting or firewall rules. Check out tools like Fail2Ban or Wordfence if you’re on WordPress.
Yep, that’s how you do it! But like others said, shady crawlers might ignore it.

If you’re on Apache, you could also use .htaccess to block everything but robots.txt:
```
<Files *>
Deny from all
</Files>
<Files robots.txt>
Allow from all
</Files>
```
Works like a charm.
disallow all except for robots.txt is easy with that code, but it’s not foolproof.

Some bots just don’t care. You could also use server-level blocking or Cloudflare’s bot fight mode.

Also, check your logs to see who’s still crawling—might need to block IPs manually.
Your robots.txt setup is right, but yeah, some bots are jerks and ignore it.

For better control, try using a firewall or mod_security rules. Tools like Sucuri or Cloudflare can help automate this.

Also, monitor your traffic—some bots might still sneak in.
Thanks everyone! Super helpful. I’ll try the .htaccess method since some bots are ignoring the robots.txt rules.

Quick follow-up: anyone know if Cloudflare’s bot protection is worth it for this? Or should I just stick to server-side blocking?

Also, my logs are a mess—any tools to help filter out legit vs. bad bots?
That’s the right way to disallow all except for robots.txt, but it’s more of a suggestion than a hard block.

If you’re serious about blocking everything else, consider server-side restrictions. NGINX or Apache rules can enforce it strictly.
Your code works for disallow all except robots.txt, but bad bots will bypass it.

Try combining it with IP blocking or CAPTCHAs for sketchy traffic. Tools like Distil or Imperva can help too.
Yep, that’s the classic method for disallow all except robots.txt. But like everyone’s saying, it’s not 100%.

For tighter control, use .htaccess or server configs to physically block access to other files.

Also, check out Bot Protection services—they’re worth it if you’re getting hammered.



Users browsing this thread: 1 Guest(s)