PDA

View Full Version : Selective Page Display based on IP Address?


Neil
10-26-2002, 05:01 PM
Hi,

I was wondering if there is any way of displaying pages based on the IP address of the person browsing the Intranet.

We have a number of locations which have their own address range as follows

192.XX.Y.nnn

Each location has a 3 digit code to identify it which is as follows:

XXY

Therefore what I want to do is interogate the IP address and extract the XXY from the IP addres, then

if XXY = 101 display page_1
else if XXY = 102 display page_2
etc etc.

All they will see on the web page is a URL to site specific info, but behind that URL is the check and send to the correct page for that site.

I don't know if I have explained it well but if you can follow it, please let me know any ideas you have.

By the way, the level above this would need to be password protected.

Neil

Mhtml
10-27-2002, 08:12 AM
Can you use a serverside language?

Neil
10-29-2002, 08:42 AM
Thanks for the reply.

I am fairly new to this, therefore I am not sure teh best wat to proceed.

I thought about having an IP check within the browser using either Java or VB and then open the appropriate page, however I was note sure if this ould be done from a single hyperlink.

What were you thing in relation to the server side app. I don't have any problems with that if it is the best solution.

Thanks again,

Neil

firepages
10-29-2002, 12:35 PM
whichever language you use the logic is still basically the same, you want the REMOTE_ADDR CGI variable

i.e. in PHP


<?
/*get last 3 digits*/
$bit=substr($_SERVER[REMOTE_ADDR],-3);
$addr['123']='page_for123.htm';
$addr['127']='page_for127.htm';
header("location:$addr[$bit]");
?>


if you have apache, mod_rewrite can redirect your pages at the time of request... but using an intranet you are probably not on apache .... sigh ;) ... I assume IIS/whatever have similar capabilities.