Banned refering urls redirect script

Discussion in 'PHP' started by joesgraphics, Jan 4, 2007.

  1. #1
    HI i would like to have a list of banned urls to be redirected to a page i want. :)
     
    joesgraphics, Jan 4, 2007 IP
  2. vinodkv

    vinodkv Peon

    Messages:
    183
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    banned url? please give us a detailed description of what you want...
     
    vinodkv, Jan 4, 2007 IP
  3. solidphp

    solidphp Peon

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey joesgraphics,
    Does this help?

    <?PHP
    $banned_url='http://url-to-send-banned.com';
    $banned=array('site1.com', 'site2.com', 'site3.com');
    
    if (in_array($_SERVER['HTTP_HOST'], $banned))
    	{
    	die(header("Location: {$banned_url}"));
    	}
    ?>
    PHP:
    This needs to be as close as possible to the top of the file because of the header() function call. Otherwise, if data is sent to the browser before the header() call in your script there will be PHP warnings. If you can't put this at the top of your script for whatever reason, change the die(header()); to echo "<script> window.location='{$banned_url}'; </script>";

    - Andy
     
    solidphp, Jan 4, 2007 IP
  4. joesgraphics

    joesgraphics Peon

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK that is the thing i needed thank you so much your a star :) thanks.
     
    joesgraphics, Jan 5, 2007 IP