Professional Documents
Culture Documents
{ sales@ip2location.com }
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 ASP (server side scripting language) and MS-SQL (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.
So, let us develop a simple solution to help Company XYZ redirecting all Internet traffic
from country Japan to the Japanese language site. Meanwhile it drives the traffic from
the rest of the world to the corporate web site in English.
In this tutorial, we use the IP2Location™ IP-Country database to lookup country of origin
from the visitor's IP address. Instead of loading the full database with 50000+ records,
we could simplify this tutorial with assumption only two different IP address ranges in
the world. IP addresses 0.0.0.0 - 126.255.255.255 originate from United States.
Meanwhile, IP addresses 127.0.0.0 - 255.255.255.255 originate from Japan. Here we
are creating a database "IP2Location" with table "IPCountry" that consists of two IP
address range records.
Step 1: Start SQL Query Analyzer. Create and connect to 'IP2Location' database
CREATE DATABASE IP2Location;
USE IP2Location;
<%
Dim conn, myDSN, mySQL, rs
myDSN=
"DRIVER={SQLServer};SERVER=servername;UID=username;PWD=password;DATABASE=I
P2Location"
conn.open myDNS
Place this script as the default script of the web site. All visitors will go through this
screening before redirect to an appropriate web page.