...

View Full Version : IP address redirection (using JavaScript or PHP?)



reapercharlie
05-08-2007, 01:31 AM
Right now what I have is an .htaccess file which blocks users not on my ip address list. But what I really want is a filter that will gather the ip address of the viewer, compare it against the server's ip address list, and redirect the viewer to a certain other link based on the viewer's ip address.

example:
user types in www.example.com, and according to ip address, is redirected to their own personal subdomain:

192.168.0.1 > mark.example.com
192.168.0.2 > john.example.com
192.168.0.3 > jerry.example.com
192.168.0.4 > tank.example.com
127.0.0.1 > zomgpwned.example.com

...and so on and so forth. Does anyone know how to do that? Any help is greatly appreciated!

antimatter15
05-08-2007, 01:42 AM
you probably need php, to get the ip address, and to store the ip database for the privacy of your clients.

JUD
05-08-2007, 01:52 AM
<?php
$rem_addr = $_SERVER['REMOTE_ADDR'];

switch($rem_addr){
case '192.168.0.1':
$user = 'mark';
break;

case '192.168.0.2':
$user = 'john';
break;

case '192.168.0.3':
$user = 'jerry';
break;

case '192.168.0.4':
$user = 'tank';
break;

case '127.0.0.1':
$user = 'zomgpwned';
break;

default:
$user = 'www'
break;
}

if($user != 'www') header('Location: http://' .$user. '.example.com');
else header('Location: http://www.google.com');
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum