Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Re: Proper way to redirect on specific countries with GeoIP

$
0
0
Use nginx map module: http://nginx.org/en/docs/http/ngx_http_map_module.html#map

The below example will work only when accessing the root location, e.g. http://yoursite/


http {
....
map $geoip_country_code $new_home_uri {
default /en/;
uk /en/;
us /en/;
de /de/;
ru /ru/;
}
....
}


server {

....

location = / {
rewrite ^ $new_home_uri break;
}

location = /de {
# default home for german visitors
...
}

location = /ru {
# default home for russian visitors
...
}

location = /en {
# default home for american, british and any other visitors
...
}

}

Viewing all articles
Browse latest Browse all 53287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>