1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

redirect visitors based on referrer

Discussion in 'PHP' started by mberman84, Feb 10, 2009.

  1. #1
    basically, what i want to do is redirect all visitors that DO NOT come from website.com. i want to have all variations of website.com redirect to A, and any other website redirect to B.

    so, website.com, www.website.com, sub1.website.com, website.com/dir1 etc etc all go to A


    and any other referrer goes to B. how do i do this?
     
    mberman84, Feb 10, 2009 IP
  2. NuLLByTe

    NuLLByTe Active Member

    Messages:
    382
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    80
    #2
    
    $ref = $_SERVER['HTTP_REFERER'];
    $desired = 'http://your-desired-reffering-page.com';
    if ($ref != $desired)
    {
    header('Location:http://site.com/wrong-referer');
    }
    else
    {
    header('Location:http://your-site.com/');
    }
    
    PHP:
     
    NuLLByTe, Feb 10, 2009 IP