# ANTI-CRAWLING PROTECTION FOR APACHE
# Block all social media crawlers and preview bots

# Block Telegram bot
RewriteCond %{HTTP_USER_AGENT} TelegramBot [NC]
RewriteRule .* https://google.com [R=302,L]

# Block Facebook crawler
RewriteCond %{HTTP_USER_AGENT} facebookexternalhit [NC]
RewriteRule .* https://google.com [R=302,L]

# Block Twitter bot
RewriteCond %{HTTP_USER_AGENT} Twitterbot [NC]
RewriteRule .* https://google.com [R=302,L]

# Block WhatsApp crawler
RewriteCond %{HTTP_USER_AGENT} WhatsApp [NC]
RewriteRule .* https://google.com [R=302,L]

# Block LinkedIn bot
RewriteCond %{HTTP_USER_AGENT} LinkedInBot [NC]
RewriteRule .* https://google.com [R=302,L]

# Block Slack bot
RewriteCond %{HTTP_USER_AGENT} Slackbot [NC]
RewriteRule .* https://google.com [R=302,L]

# Block Discord bot
RewriteCond %{HTTP_USER_AGENT} DiscordBot [NC]
RewriteRule .* https://google.com [R=302,L]

# Block generic crawlers
RewriteCond %{HTTP_USER_AGENT} (bot|crawl|spider|scraper|preview|fetch|parser|extractor) [NC]
RewriteRule .* https://google.com [R=302,L]

# Security headers
Header always set X-Robots-Tag "noindex, nofollow, nosnippet, noarchive, noimageindex"
Header always set Cache-Control "no-cache, no-store, must-revalidate"
Header always set Pragma "no-cache"
Header always set Expires "0"