Need meta refresh to send to a different site when referrer contains certain words

Discussion in 'PHP' started by vetting, Jul 16, 2008.

  1. #1
    Need meta refresh to send to a different site when referrer contains certain words.

    So if the referrer contains words such as:
    mail
    google
    ebay

    Send traffic to link A

    if anything else

    Send to link B

    Thanks for your help
     
    vetting, Jul 16, 2008 IP
  2. mbreezy

    mbreezy Active Member

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    
    $redirectflag = substr_count($_SERVER['HTTP_REFERER'], 'google') + substr_count($_SERVER['HTTP_REFERER'], 'mail') + substr_count($_SERVER['HTTP_REFERER'], 'ebay');
    
    if($redirectflag > 0)
        header('location:http://www.SITEA.com');
    else
        header('location:http://www.SITEB.com');
    
    PHP:
     
    mbreezy, Jul 17, 2008 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    
    if (isset($_SERVER['HTTP_REFERER']) AND preg_match('~google|mail|ebay~i', $_SERVER['HTTP_REFERER']))
    {
        // Redirect to A
    }
    else
    {
        // Redirect to B
    }
    
    PHP:
     
    nico_swd, Jul 17, 2008 IP
  4. mbreezy

    mbreezy Active Member

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    I like that one more. :)

    I dunno why, but I write some real dirty code, always have. I can make just about anything happen, but it's grimy. haha I <3 globals. (yeah, i get that bad)
     
    mbreezy, Jul 17, 2008 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Lol, your code is more creative, though. :p No one is gonna take you that!
     
    nico_swd, Jul 17, 2008 IP
  6. vetting

    vetting Peon

    Messages:
    193
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Awesome - thanks for the help.
     
    vetting, Jul 17, 2008 IP