1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect based on referrer?

Discussion in 'CPA' started by icekold, Nov 25, 2008.

  1. icekold

    icekold Newbie

    Joined:
    Nov 27, 2007
    Messages:
    18
    Likes Received:
    2
    Hey guys...

    maybe someone here can help me out. I need some code to redirect visitors based on the referrer. Basically i want to send traffic with a referrer to page1.php, and blank referrer traffic to page2.php

    So if someone clicks my link, I want them to go to my landing page, but if they access direct ie: type in url, send them to an error page.

    Probably easy, but I suck at this coding stuff...lol. Thanks
     
  2. turbotec

    turbotec Junior Member

    Joined:
    Apr 5, 2008
    Messages:
    181
    Likes Received:
    15
    PHP:
    <?php
        $referer 
    $_SERVER['HTTP_REFERER'];
        if(
    $referer == "http://www.yoursite.com/referrer-you-want-it-to-be.php")
        {
            echo 
    '<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/page1.php">';
        }
        else
        {
            echo 
    '<meta http-equiv="refresh" content="0;url=http://www.youfail.org/">';    
        }
    ?>
     
    • Thanks Thanks x 1
  3. WickednDivine

    WickednDivine Executive VIP Premium Member

    Joined:
    Jul 29, 2008
    Messages:
    468
    Likes Received:
    344
    just another alternative:

    Code:
    
    <?php
    
    $referrer = $_SERVER['HTTP_REFERER'];
    
    if($referrer == ""){
        header("HTTP/1.1 404 Not Found");
    }
    
    ?>
    
    
     
    • Thanks Thanks x 1
  4. icekold

    icekold Newbie

    Joined:
    Nov 27, 2007
    Messages:
    18
    Likes Received:
    2
    Thanks a bunch guys...

    Tried each on seperate campaigns, and they both work great. Thanks for helping a newbie out. Pushed the little button for ya too!