Nginx configuration to identify bots

Mir Adnan
1 min readJul 7, 2018

--

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;}

--

--

Mir Adnan
Mir Adnan

No responses yet