本文介绍了识别用户位置/IP &更改语言.基于此的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题很清楚.

我的网站包含英文版和西班牙文版.您可以通过单击 http://www.chrishonn.com 转到西班牙语的主站点,然后http://en.chrishonn.com 的英文翻译版本.在每个页面的索引处都有一个链接(在底部),允许用户从一个站点传递到另一个站点.

My websites consists of both English-written and Spanish-written versions.You can go to the main site, which is in Spanish, by clicking http://www.chrishonn.com and to the translated version, which is in English, at http://en.chrishonn.com. At the index of each page there is a link (at the bottom) which allow the user to pass from one site to the other.

但是,我想知道,像 Google、Yahoo! 和其他品牌的网站这样的大型网站如何识别用户的地理位置/IP,以便 - 取决于它 - 调整网站的语言(即你来自中国并且您访问 www.google.com,您将被重定向到 www.google.cn).

However, I was wondering, how do big sites like Google, Yahoo!, and other brands' websites to recognize the user's geographical location/IP so that - depending on that - the site's language is adapted (i.e. you are from China and you visit www.google.com, you'll be redirected to www.google.cn).

我在我网站的每一页上都注明了语言:

I have stated on every single page of my website the language:

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

该示例当然来自 http://en.chrishonn.com 网站之一,这些网站是英文.

That example is of course from one of the http://en.chrishonn.com sites, which are in English.

我希望有人能帮帮我.谢谢(如果我遗漏了什么,请告诉我).

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

推荐答案

对于 Google,您的位置是根据您的 IP 地址确定的.从美国境外向 google.com 发出的请求会返回一个 HTTP/1.1 302 Found,它将您重定向到您所在国家/地区的特定域.

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

正如另一篇文章中所讨论的,进行此类重定向会使 SEO 变得棘手和复杂.我建议阅读 Matt Cutt 的文章(一位 Google 软件工程师),了解 Google 如何处理 302 重定向:SEO 建议:讨论 302 重定向.

As also discussed on another post, doing these kinds of redirects can make SEO tricky and complicated. I suggest reading Matt Cutt's article (a Google software engineer) on how Google handles the 302 Redirect: SEO advice: discussing 302 redirects.

不同的搜索引擎以不同的方式处理 302 重定向.使用 302 重定向,您的原始域可能会被搜索引擎忽略.

Different search engines handle the 302 redirect in a different way. With 302 redirects, you may risk having your original domain ignored by search engines.

如果您想根据用户的 IP 地址确定用户的位置,可以使用许多现成的服务,它们基本上将大部分 IP 范围映射到国家/地区.您可能需要检查:

If you want to determine your users' location from their IP address, there are many off-the-shelf services which basically map most of the IP ranges to countries. You may want to check:

另一种流行的技术是解析 Accept-Language HTTP 标头,其中包含有关用户语言偏好的信息.主流浏览器允许用户修改这些语言偏好.您可以从以下网址了解更多关于此技术的信息:

Another popular technique is to parse the Accept-Language HTTP header, which contains information about the user's language preferences. Mainstream browsers allow these language preferences to be modified by the user. You may read more about this technique from:

这篇关于识别用户位置/IP &amp;更改语言.基于此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 05:42