Javascript Redirect Referrering Domain

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thonglife
    So Fucking Banned
    • Oct 2004
    • 1566

    #1

    Javascript Redirect Referrering Domain

    I used to have a small javascript snippet that would redirect incoming visitors from a specific (and only that) domain to elsewhere on the web. In this case, I need to send some hotlinking forum users elsewhere...ie.. dvdtalk.com. I've looked all over and can't find the script I used to have. I don't need htaccess redirects.. only a single webpage redirect based on the referrering domain. Please post the code if you have/know. Much obliged!
  • Dynamix
    G F Y not
    • Jan 2004
    • 2910

    #2
    Not sure on JS, but you could use PHP:

    Code:
    <?php
    $bad_domain = "charter.com";
    $hostname = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
    $pos = strpos($hostname, strtolower($bad_domain));
    
    if ($pos hahahaha= false) { } else {
    // Offending domain, redirect
    header("Location: http://www.aol.com/");
    }
    ?>
    The code should be placed on the top line of the document you are trying to protect.

    TGPFactory Full TGP Design & Installation Services
    ICQ 250 142 484 · AIM TGPDynamix · Email: patrick (at) tgpfactory (dot) com
    See who I am at AdultWhosWho.com!

    Comment

    • Dynamix
      G F Y not
      • Jan 2004
      • 2910

      #3
      damn gfy.. replace the 'hahahaha=' with three equals signs

      TGPFactory Full TGP Design & Installation Services
      ICQ 250 142 484 · AIM TGPDynamix · Email: patrick (at) tgpfactory (dot) com
      See who I am at AdultWhosWho.com!

      Comment

      • thonglife
        So Fucking Banned
        • Oct 2004
        • 1566

        #4
        Originally posted by Dynamix
        Not sure on JS, but you could use PHP:

        Code:
        <?php
        $bad_domain = "charter.com";
        $hostname = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
        $pos = strpos($hostname, strtolower($bad_domain));
        
        if ($pos hahahaha= false) { } else {
        // Offending domain, redirect
        header("Location: http://www.aol.com/");
        }
        ?>
        The code should be placed on the top line of the document you are trying to protect.

        Comment

        Working...