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

Looking for a php script which redirects all hits from referres but one

Discussion in 'PHP & Perl' started by peetu69, Feb 25, 2011.

  1. peetu69

    peetu69 Jr. VIP Jr. VIP Premium Member

    Joined:
    Dec 7, 2010
    Messages:
    194
    Likes Received:
    131
    Location:
    420
    Hello,

    im loooking for a simple php script, which redirects all visits/hits from ALL referrers but one.

    so basically in pseudo code it would look like this:

    i have no idea from php and only basic knowledge in programming from my studies.

    Can anyone experienced help me?

    Thanks :)
     
  2. BugFixed

    BugFixed Junior Member

    Joined:
    Sep 24, 2010
    Messages:
    130
    Likes Received:
    39
    PHP:
    $ref=isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    $target_url "http://www.example.com/page3";
    $src="mydomain.com";
    if (
    $ref !== $src) {
      
    header('Location: '.$target_url);
    }
     
    • Thanks Thanks x 2
  3. peetu69

    peetu69 Jr. VIP Jr. VIP Premium Member

    Joined:
    Dec 7, 2010
    Messages:
    194
    Likes Received:
    131
    Location:
    420
    hey, that looks great!

    i think it works, will try it now, thanks a lot!