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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

(PHP) Redirection Based on IP - Problem?

  • 22-07-2009 10:52am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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