Why redirect web visitors based on country
There are times when it is useful to redirect a visitor to different default web page based on the visitor’s country of origin. One practical usage is to redirect visitor to web page with the language recognized by the visitor. This article shows you how to build up such a system using PHP (server side scripting language) and MYSQL (IP address to country lookup database).
Let us take a simple case study. Company XYZ is multi-national company with major customers from United States and Japan. The company official website is developed in both English and Japanese languages. The default page is in English language and visitor can switch to Japanese by changing the default language option. There exists a potential risk when a Japanese visitor does not understand English and he could not navigate the web site.
How to redirect web visitors based on country
In this tutorial, we use the IP2Location™ IP-Country database to lookup country of origin from the visitor’s IP address.
Below are the steps to set up the database for both IPv4 and IPv6 data and the sample codes