开发者

How to load a different language URL depending on the visitor's IP in a multingual site? [closed]

开发者 https://www.devze.com 2022-12-31 08:12 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_运维问答
Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_运维问答

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

Some time ago I developed a multilingual website and now they have asked me that the website should load the language depending on the visitor's IP address. They are going to provide me with an IP address list of different countries.

For example. If an italian visitor loads the website, the website should load www.mydomain.com/it

If the IP is not recognised, the website should load www.mydomain.com

How can I achieve this?

Thanks in advance.

Regards


I found a solution and it worked perfectly for me.

I found a site which provides a database table with all the necessary ips and locations. The site can be found at:

http://www.ip2nation.com/

You can download both the sql dump and the php code sample from there.


You could also use the Accept-Language request header: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html http://www.w3.org/International/questions/qa-lang-priorities.en.php

You could write a redirect in Apache or NGINX to redirect to a different site based on that header.


This is one of Joomla plugins that help you in such case.. But this works only if your site is a Joomla site.

extensions.joomla.org/extension/language-domains

Else, set redirects to each language domain.. there are many ways for doing this.. you can google for these.

Solutions above are provided based on the idea of setting a domain to each language/country (EXP: .jp, .ir,. de,etc....)

If you have only one domain, with content is divided lingually in directories (site.com/ar, site.com.jp, site.com/en) you can set links in homepage.. if you want this to be done automatically create a script to get visitor`s country and automatically redirect him to his content.. this step can be done easier with solutions recomemnded for you earlier.

0

精彩评论

暂无评论...
验证码 换一张
取 消