Nginx configuration to identify bots

Here’s a simple configuration that will identify bots and redirect them to unsupported page.

location / {   set $isbot 0;   if ($http_user_agent ~* "googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|bot|curl|wget|facebookexternalhit|twitterbot|developers\.google\.com") {
set $isbot 1;
}
if($isbot) {
# bot identified...
rewrite .* /$scheme://$host/unsupported.html break;
}
try_files $uri $uri/ /index.html;}

Written by

Product Lead at StegoSOC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store