Skip to content

Instantly share code, notes, and snippets.

@sadiqsalau
Created January 12, 2025 03:38
Show Gist options
  • Save sadiqsalau/8fcee7b5faf9a1f8d25767e581972ab9 to your computer and use it in GitHub Desktop.
Save sadiqsalau/8fcee7b5faf9a1f8d25767e581972ab9 to your computer and use it in GitHub Desktop.
Redirect Crawlers to Backend
Options -MultiViews
RewriteEngine On
# Enable Https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet|LinkedInBot|Slackbot|Discordbot|WhatsApp|TelegramBot|Applebot|Bingbot|YandexBot|DuckDuckGo-Favicons-Bot|Sogou|Exabot|Baiduspider|SeznamBot|ahrefsbot|MJ12bot|DotBot|ia_archiver|Embedly|W3C_Validator) [NC]
RewriteRule ^(.*)$ https://backend.example.com/og/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment