Print Page | Close Window

Serving different pages depending on IP

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10250
Printed Date: 31 March 2026 at 4:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Serving different pages depending on IP
Posted By: Nathan
Subject: Serving different pages depending on IP
Date Posted: 01 May 2004 at 3:26pm

I have a travel site for the Greek island of Corfu, and would like to serve the Greek text pages to Greek visitors, and English text pages to everyone else.

I think all Greek IP addresses start with 212.

 

I assume the following:

if 'IP starts with 212' then

     include Greek text

else

     include English text

end if

 

Could anyone help me code the expression - 'if IP starts with 212'

Also, does anyone know how I can find out if 212 does indeed cover all of the Greek IP address.

Thanks for any help you can offer.

Nathan

http://www.corfu-travel-guide.info - www.corfu-travel-guide.info

http://www.agni.gr - www.agni.gr

 

 




Replies:
Posted By: Mikael
Date Posted: 01 May 2004 at 4:27pm

I would use asp servervariables inbuild language-tool to get the users language:

If Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") = "gr" Then....

The answer of your IP-based question:

If Mid(Request.ServerVariables("REMOTE_ADDR"), 1, 3) = "212" Then

key: Mid(string,start[,length])


Posted By: weppos
Date Posted: 01 May 2004 at 4:29pm
Quote Could anyone help me code the expression - 'if IP starts with 212'


You can use

If Left(Request.ServerVariables("REMOTE_ADDR"), 3) = "212" Then

    'Do something
End If


... anyway....

Quote Also, does anyone know how I can find out if 212 does indeed cover all of the Greek IP address.


...I suggest you to get client country using IP address and information provided by ip-to-country.
http://ip-to-country.webhosting.info/ - Follow this link

It allows you to create and query an IP database to find the right client country.


Posted By: weppos
Date Posted: 01 May 2004 at 4:31pm
Originally posted by Mikael Mikael wrote:

I would use asp servervariables inbuild language-tool to get the users language:If Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") = "gr" Then....




It's only quite correct.
For example I usually use Netscape or Firefox and they tell you I'm english, while I'm italian.


Posted By: dpyers
Date Posted: 01 May 2004 at 5:17pm

Corfu is a beautiful place. Went there years ago after I was asked to leave Italy .

The ip number method of identifying a country is not reliable. IP addresses are not assigned by country. They are assigned by the ICANN to  Local Internet Registries (LIR's). There are 4 of them - IIRC, Europe is covered by an organization called RIPE. An LIR will assign a block of numbers to major backbone providers - e.g. British Telcom, ATT, etc. How the backbones distribute is up to them. The backbone provider for 212 could use some part of that range of numbers for Greece, some for Finland, and some for the Azores.

ISP's get their numbers from the back-bone providers - an ISP in Greece might have both British Telcom and AT&T. Part of their number ranges might start with aaa from ATT, part with yyy from BT.

What ip number an end user winds up with will also depend on the location of their isp. Many isp's have branches in different countries. AOL is the best example. Your users may have a greek isp that is a branch, or gets ip numbers from a larger isp in Germany.

If I were you however, I'd still take my best guess. I'd check for number, country code on their http_referer, amd language. If you see anything that looks like it's Greek, send them to the Greek page with an English link-out on it.

http://ip-to-country.webhosting.info/ - http://ip-to-country.webhosting.info/  has tools for playing around with country stuff.

EDIT - Did a quick look up. The 212 block is held by ATT. A quick whois check of some numbers - e.g. 212.1.1.1, 212.200.200.200, etc., from the RIPE data base - http://www.ripe.net/db/whois/whois.html - http://www.ripe.net/db/whois/whois.html  -Turned up addresses in Great Britain, The Channel Islands, Holland, and Germany.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Nathan
Date Posted: 02 May 2004 at 3:16am

Thank you very much for such comprehensive answers and helpful advise. I will try a bit of fiddling and report back. Interestingly of course this is going to be difficult to test as I live in Greece. I'll enlist the help of some of my site members to test the system.

Thanks Again.

Nathan



Posted By: dj air
Date Posted: 04 May 2004 at 2:17pm

may i ask why not just write / flags where the uer can clcik a link/image with the name of the language so it is their flags or English and greek (in greek)..



Posted By: weppos
Date Posted: 04 May 2004 at 3:41pm
Originally posted by dj air dj air wrote:

may i ask why not just write / flags where the uer can clcik a link/image with the name of the language so it is their flags or English and greek (in greek)..



Sorry, I can't understand.


Posted By: dj air
Date Posted: 05 May 2004 at 9:07am

in stead of using the IP,

why not use a link to set the language in a cookie so if they click greek then a cookie/session verable is set and that is then read in to site

and ise some code like below to set the language of the site

' read in the language setting from a cookie/session
strLanguage = request("Language")

if strLanuage = "Greek" then

code for the language

Else

code for english

END IF



Posted By: dpyers
Date Posted: 05 May 2004 at 11:49am

Sounds like the best solution is to have an entry page that has 2 little flags on it - one Greek, and one English. Caption under each flag should say something like "View this site in xxxx".

If they click on the Greek flag, set a language cookie and then redirect them them to the Greek transaltion. Do the same thing for the English.

You'll want the fist thing on the entry page to be a check for the cookie and route them accordingly. so the next time they come there, they go directly to the right translation.

On the home page for each translation, you should also have the flag that allows them to go to the other translation,



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Bluefrog
Date Posted: 11 May 2004 at 11:51am

When it comes to language, you should only ever HELP the user - don't ever decide for them. The best way is to use the language indicator in the HTTP headers (most reliable) first and country second (embassy personelle, expats, countries with more than 1 language, etc.). Make sure to have a language link on every page for users to change. I hate entry pages, but a http-equiv redirector is ok... (yuck) Users should not have to click through the entry page - i.e. help them out there with redirection.

The important thing is to always leave it in the user's hands ultimately. Some major sites really screw this up and it is horribly annoying. I could list a million reasons why, but... I'm lazy  



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net