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
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]
It still does not have any info to remove googlebot from redirection.
location / {
include proxy-lcb-lt.conf;
if ($geoip_country_code = "US") {
proxy_pass http://prod;
}
# these are the exceptions, defined in nginx.conf:
if ($mygeo = "1") {
proxy_pass http://prod;
}
}
Thank you for the reply, i`m going to try using this on my
configuration, i was thinking to exclude it by referrer which googlebot
uses but maybe using ip would work too, in fact the ips would change.
Just to confirm, your configuration works fine, i have applied it today,
still wondering if it would be better to use refferrer or ip ? Any
suggestions ? Thank you.