Rainer Duffner
November 17, 2010 02:02PM
Am 17.11.2010 um 13:55 schrieb st1905:

> 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.



We did it like this (not for google - you have to find their ip-space)


http {
keepalive_timeout 65;
geoip_country /usr/local/etc/geo/GeoIP.dat ;

# these are the GeoIP exceptions for your site
geo $mygeo {
default 0;
bla/19 1;
blu/16 1;
}


then, in the server block:

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



Hope this helps.



Rainer

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx geoip redirect based on country codes but exclude googlebot

st1905 November 17, 2010 07:55AM

Re: Nginx geoip redirect based on country codes but exclude googlebot

Rainer Duffner November 17, 2010 02:02PM

Re: Nginx geoip redirect based on country codes but exclude googlebot

st1905 November 18, 2010 04:53AM

Re: Nginx geoip redirect based on country codes but exclude googlebot

st1905 November 18, 2010 06:36AM

RE: Nginx geoip redirect based on country codes but exclude googlebot

Hendrik Hardeman November 18, 2010 09:56AM

Re: Nginx geoip redirect based on country codes but exclude googlebot

st1905 November 18, 2010 12:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 270
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready