Why robots.txt is not enough
Every AI company publishes the name of its crawler and promises to respect robots.txt. Some do. Many scrapers do not, and a robots.txt line is a polite request that a bot can read and ignore. If you want pages to actually stay out of a crawler’s hands, the check has to happen on your server, before the page is rendered.
The second problem is scale. OpenAI alone runs three agents (GPTBot, OAI-SearchBot, ChatGPT-User). Add Anthropic, Perplexity, Meta, Amazon, Apple, ByteDance, Common Crawl, then the SEO crawlers (AhrefsBot, SemrushBot, MJ12bot) and the scanners. Keeping that list by hand in .htaccess is a job nobody wants.
What php-anticrawler does
php-anticrawler is a free, open-source PHP library by CleanTalk: https://github.com/CleanTalk/php-anticrawler. It sits at the top of your page logic and makes one decision per visit: let it through or show a block screen.
- Recognises 100+ known bots by User-Agent, including GPTBot, OAI-SearchBot, ClaudeBot, PerplexityBot, Google-Extended, Applebot-Extended, meta-externalagent, Amazonbot, Bytespider and CCBot. The list is maintained in the CleanTalk cloud and updated as new agents appear, you do not edit it by hand.
- Lets you allow any of them. Want Google-Extended for AI Overviews but not GPTBot? Two lines in the allow list.
- Checks visitors against CleanTalk IP block lists and your personal lists when you add an API key (optional).
- Shows no CAPTCHA to real people. A lightweight JavaScript check sets a cookie once, humans never see it.
- Runs anywhere PHP runs: SQLite on shared hosting, KeyDB on a cluster.
Installation in three steps
- Install the package:
composer require cleantalk/php-anticrawler - Copy
cleantalk-anticrawler.jsto your public directory and add it to your page:<script src="/path/to/cleantalk-anticrawler.js"></script> - Add the check to your PHP entry point:
use Cleantalk\PHPAntiCrawler\CleanTalkAntiCrawler;
$ac = new CleanTalkAntiCrawler([]);
if ($ac->badVisitor()) {
$ac->showAccessDeniedScreen();
exit;
}
That is the whole setup. Denied visitors get a 403 and a block page you can replace with your own template.
Keeping the good bots
The basic setup blocks every known crawler, Googlebot and Bingbot included. For a public site you want them in. Pass the agents you trust to the allow list in the constructor, and the library skips them. The same works in reverse: if a bot from the trusted list is eating your bandwidth, add it to your block list. The full list of agents the library knows is published and updated at https://cleantalk.org/help/filter-ua.
How it compares
| robots.txt | Manual .htaccess rules | CAPTCHA on every page | php-anticrawler | |
|---|---|---|---|---|
| Stops bots that ignore rules | No | Yes, if you keep up | Yes | Yes |
| Maintenance | None | Constant | None | None, list is in the cloud |
| Effect on real visitors | None | None | Friction on every visit | None |
| New AI crawlers | You add them | You add them | N/A | Added for you |
Who it is for
Sites on custom PHP, Laravel, Symfony, Yii or any framework where you control the entry point. WordPress users get the same protection with the Anti-Crawler option in the CleanTalk Anti-Spam plugin, no code needed.
Try it
Repository, documentation and the list of supported bots: https://github.com/CleanTalk/php-anticrawler. If it saves you a .htaccess afternoon, a star on GitHub helps other PHP developers find it.
Related: CleanTalk Anti-Flood and Anti-Crawler options for WordPress, https://cleantalk.org/help/anti-flood-and-anti-crawler. Supported User-Agents: https://cleantalk.org/help/filter-ua.