A website that recognizes user location / IP and changes. based on this

Headline

pretty simple.

My sites consist of English and Spanish versions. You can go to the main site, which is in Spanish, by clicking on http://www.chrishonn.com and the translated version, which is in English, at http://en.chrishonn.com . In the index of each page there is a link (below) that allows the user to go from one site to another.

However, I was wondering how large sites such as Google, Yahoo !, and sites of other brands recognize the user's geographical location / IP address, so - depending on this - the language of the site is adapted (i.e. you from China and you visit www.google.com, you will be redirected to www.google.cn).


I indicated on each page of my site the language:

<meta http-equiv="content-language" content="en"> 

This example, of course, refers to one of the http://en.chrishonn.com sites that are in English.

Hope someone can give me a hand. Thank you (if I missed something, let me know).

+7
javascript html geolocation website
source share
6 answers

As for Google, your location is determined from your IP address. A request to google.com from outside the United States returns HTTP/1.1 302 Found , which redirects you to your specific domain.

As also discussed in another post , doing these kinds of redirects can make SEO complicated and complex. I suggest reading an article by Matt Cutt (a Google software developer) about how Google handles 302 redirects: SEO tip: A discussion of 302 redirects .

Various search engines handle redirects 302 differently. With 302 redirects, you may find that your source domain is ignored by search engines.


If you want to determine the location of your users on your IP address, there are many off-the-shelf services that basically display most of the IP ranges for countries. You can check:


Another popular method is to parse the Accept-Language HTTP header, which contains information about custom language settings. Major browsers allow you to change these language settings by the user. You can learn more about this method:


+10
source share

Instead of determining the location of the IP address (often unreliable due to NAT and proxying), you can check the default language in which the browser is installed. JQuery plugins are supported for this, such as http://keith-wood.name/localisation.html or use server-side code to read the HTTP-HTTP header "HTTP_ACCEPT_LANGUAGE" to determine if you want to show the ES or EN site.

+12
source share

some website uses geolocation based on IP address, some of us accept the language header of the language (can be installed in the browser). In any case, from the point of view of ease of use - always let people change their language and never display different materials on the same IP address (google and other search engines do not like him, and this would be bad from the point of view of SEO).

+1
source share

These sites often use tools that are commonly referred to as "geolocation software."

One of the most popular packages is the free GeoLite Country database offered by MaxMind. It integrates into your application and provides IP address lookups. With Apache, you will have some environment variables set with the names GEOIP_COUNTRY_CODE and GEOIP_COUNTRY_NAME.

Your entire application should be executed after it decides where your user should be, or what parameters they should have by default depending on the country, and also redirect or output accordingly.

+1
source share

You can make a GET request at this URL: https://api.teletext.io/api/v1/geo-ip and it will respond with some country information in JSON format. See https://teletext.io/help/geo-location-service for use.

If you want to implement it yourself: I installed it using AWS Cloudfront, Cloudfront adds the (Cloudfront-Viewer-Country) header to your request before it redirects it to the source server, which you can use. Make sure whitelisting is included in your Cloudfront distribution.

0
source share

I created a cloud distribution and white is the CloudFront-Viewer-Country header. But when I accessed the object using this distribution, I did not see it in the request header.

0
source share

All Articles