<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
    RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget|python|perl|php|ruby|go-http|libwww|fetch|httpclient|okhttp|axios) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (bot|crawler|spider|scraper|crawl|scan|scanner) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|yandex|baidu|duckduckbot|slurp) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (semrush|ahrefs|mj12bot|dotbot|screaming.frog) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (headless|phantom|selenium|puppeteer|playwright) [NC]
    RewriteRule .* - [F,L]
</IfModule>

<IfModule mod_setenvif.c>
    SetEnvIfNoCase User-Agent "^$" bad_bot
    SetEnvIfNoCase User-Agent "bot" bad_bot
    SetEnvIfNoCase User-Agent "crawler" bad_bot
    SetEnvIfNoCase User-Agent "spider" bad_bot
    SetEnvIfNoCase User-Agent "scraper" bad_bot
    SetEnvIfNoCase User-Agent "curl" bad_bot
    SetEnvIfNoCase User-Agent "wget" bad_bot
    SetEnvIfNoCase User-Agent "python-" bad_bot
    SetEnvIfNoCase User-Agent "googlebot" bad_bot
    SetEnvIfNoCase User-Agent "bingbot" bad_bot
    SetEnvIfNoCase User-Agent "yandex" bad_bot
    SetEnvIfNoCase User-Agent "semrush" bad_bot
    SetEnvIfNoCase User-Agent "ahrefs" bad_bot
    SetEnvIfNoCase User-Agent "mj12bot" bad_bot
    SetEnvIfNoCase User-Agent "headless" bad_bot
    SetEnvIfNoCase User-Agent "phantom" bad_bot
    SetEnvIfNoCase User-Agent "selenium" bad_bot
    <IfModule mod_authz_core.c>
        <RequireAll>
            Require all granted
            Require not env bad_bot
        </RequireAll>
    </IfModule>
</IfModule>
