PHP redirect specific ips to page?

Discussion in 'General Scripting Chat' started by bdmedia, Apr 7, 2013.

Thread Status:
Not open for further replies.
  1. bdmedia

    bdmedia Jr. VIP Jr. VIP

    Joined:
    Nov 12, 2008
    Messages:
    341
    Likes Received:
    128
    Location:
    West COAST
  2. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,868
    Likes Received:
    1,336
    PHP:
    <?php
    // Array of special IPs
    $ipArray = array(
         
    // Format: "IP" => "Landing page"
         
    "123.45.67.890" => "lander1.php",
         
    "123.45.67.891" => "lander2.php"
    );

    // Read current user's IP
    $currentIp $_SERVER['REMOTE_ADDR'];

    // Redirect if a special IP
    if (array_key_exists($currentIp$ipArray)) {
         
    header("Location: http://www.domain.com/" $ipArray[$currentIp]);
         exit();
    } else {
         
    // If not one of the special IPs
    }
    ?>
    For all other redirects (country, device, time of day, etc) check out my redirection site: http://www.monojump.com/
     
    • Thanks Thanks x 1
    Last edited: Apr 7, 2013
  3. Known

    Known Regular Member

    Joined:
    Jan 27, 2013
    Messages:
    266
    Likes Received:
    187
    Occupation:
    IM
    Location:
    OH CANADA!!!!
    Do you mean a geo redirect script? Or are you trying to hide your real lander from your aff manager :p
     
  4. bdmedia

    bdmedia Jr. VIP Jr. VIP

    Joined:
    Nov 12, 2008
    Messages:
    341
    Likes Received:
    128
    Location:
    West COAST
    Artizhay,

    Thanks for the help! im having a small issue though. replaced the variables with the actual ips and landers i want to use, but when accessing the page from the Ips it doesn't redirect.. just stays a blank white page. Is there anything else i need to do, such as permissions etc?
     
  5. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,868
    Likes Received:
    1,336
    Sorry, use array_key_exists rather than in_array.
     
    • Thanks Thanks x 1
Thread Status:
Not open for further replies.