keyword blacklist & redirect?

Discussion in 'PHP' started by brianj, May 26, 2009.

  1. #1
    Hi, short question again..

    i have a rewrite rule:
    
    RewriteRule ^([a-zA-Z0-9]+)/?$ /index.php?keyword=$1 [L] 
    PHP:
    The problem, some keywords i want to have on a blacklist and then redirect them to another page...

    Any simple way to put such bad keyword into a blacklist?
    And maybe a formfield for that?


    Thanks for help,
     
    brianj, May 26, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You would need to use a php redirect and not an htaccess redirect to perform this. You could have the keywords in a database, text file, or just in an array.
     
    jestep, May 26, 2009 IP
  3. brianj

    brianj Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    So i use a header redirect? Any examples?
     
    brianj, May 27, 2009 IP
  4. jnugroho73

    jnugroho73 Peon

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try to create a text file that contains the keywords that you blacklist. Enter one keyword per line. Such as blacklist.txt.
    
    <?php
    $blacklist_exists = 0;
    $fblacklist = fopen('./blacklist.txt','r');
    while(!feof($fblacklist)){
            $current_blacklist = trim(fgets($fblacklist,1024));
            if(stristr($_GET['keyword'],$current_blacklist)){
                    $blacklist_exists = 1; break;
            }
    }
    fclose($fblacklist);
    header('location: your-new-url-location');
    exit;
    ?>
    
    Code (markup):
    Good Luck ;)
     
    jnugroho73, May 27, 2009 IP
  5. jnugroho73

    jnugroho73 Peon

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I am sorry, there is one line above that I have forgot.
     
    jnugroho73, May 28, 2009 IP