Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IP address redirection (using JavaScript or PHP?)

    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!

  • #2
    New Coder
    Join Date
    Apr 2007
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you probably need php, to get the ip address, and to store the ip database for the privacy of your clients.

  • #3
    JUD
    JUD is offline
    New Coder
    Join Date
    Jul 2005
    Location
    I'm right here
    Posts
    92
    Thanks
    0
    Thanked 2 Times in 2 Posts
    PHP Code:
    <?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');
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •