redirecting useres from specific referrers

Discussion in 'PHP' started by a!!!!1, Dec 9, 2008.

  1. #1
    I'm sending traffic to a .php on my server, and I want to redirect all users who come from 'google' to a specific url, and all else are redirected to another url. How do I do this? Thanks :)
     
    a!!!!1, Dec 9, 2008 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use the HTTP var to check the referrer, and then the header() function
     
    GreatMetro, Dec 9, 2008 IP
  3. a!!!!1

    a!!!!1 Peon

    Messages:
    346
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks but I barely understand PHP so writing it myself is a little hard, lol.
     
    a!!!!1, Dec 9, 2008 IP
  4. firman01

    firman01 Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    165
    #4
    
    <?php
    $ref = = $_SERVER['HTTP_REFERER'];
    
    if(strstr($ref,"google")) {
      header("Location: http://www.peoplefromgooglegohere.com/");
    } else {
      header("Location: http://www.otherpeoplegohere.com/");
    }
    ?>
    
    Code (markup):
     
    firman01, Dec 9, 2008 IP