Stop spam without frustrating your visitors

Create your CleanTalk account and start blocking spam — no CAPTCHA challenges and no impact on visitors.

Security Block Lists

CleanTalk Account

No credit card required • Setup takes less than a minute • Your temporary password will be sent by email.

How to Block AI Crawlers, Scrapers and Bad Bots on a PHP Site Without a CAPTCHA

·

,

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

  1. Install the package:
    composer require cleantalk/php-anticrawler
  2. Copy cleantalk-anticrawler.js to your public directory and add it to your page:
    <script src="/path/to/cleantalk-anticrawler.js"></script>
  3. 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.txtManual .htaccess rulesCAPTCHA on every pagephp-anticrawler
Stops bots that ignore rulesNoYes, if you keep upYesYes
MaintenanceNoneConstantNoneNone, list is in the cloud
Effect on real visitorsNoneNoneFriction on every visitNone
New AI crawlersYou add themYou add themN/AAdded 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.

Maria Krasnova Avatar

Maria Krasnova

Marketing Manager