Nginx geoip redirect based on country codes but exclude googlebot

st1905 nginx-forum at nginx.us
Wed Nov 17 15:55:36 MSK 2010


Hello,

I want to redirect people to specific pages on a website according to
their country but i dont want to redirect googlebot or other spiders,
how can i do this with nginx ?

I have done redirection with php earlier but havent been able to exclude
googlebot.

As i read from maxmind website, on apache its done like this

[code]
GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

# Redirect one country
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://www.canada.com$1 [L]

# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$
RewriteRule ^(.*)$ http://www.northamerica.com$1 [L]
[/code]


It still does not have any info to remove googlebot from redirection.

Thanks for any help.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,151401,151401#msg-151401




More information about the nginx mailing list