Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

(PHP) Redirection Based on IP - Problem?

  • 22-07-2009 11: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