Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

(PHP) Redirection Based on IP - Problem?

Options
  • 22-07-2009 11:52am
    #1
    Registered Users Posts: 345 ✭✭


    Hey Guys,

    Currently using the following code from an redirection based on IP address....

    <?php
    if(isset($_SERVER) && $_SERVER == "IP Address One")
    {
    header("Location: http://www.Site1.com);
    }
    else

    header("Location: http://www.Site2.com");
    }
    exit();
    ?>


    But how do I add mulpital visitor IP's to the code?

    Cheers,
    Paul


Comments

  • Registered Users Posts: 379 ✭✭TheWaterboy


    Not 100% sure of your actual question but ill give you an answer to what I think you are trying to achieve.

    To add multiple visitors IP addresses just put them in an array and then use the in_array() function to check if the value of $_SERVER is in this array.

    if(isset($_SERVER) {
    if (in_array($_SERVER, $myIPList)) {
    header("Location: http://www.Site1.com);
    } else {
    header("Location: http://www.Site2.com);
    }
    die();
    }


Advertisement