Php removes black hat SEO search keywords
I will give you a method. My thoughts
The idea is that most of the big guys who want to do this need to leave QQ or phone numbers.
Then I will match the rules in the search to find the numbers in the search and then determine the length of the number string to determine whether the search is spam.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<? Php // @ Function blocks search keywords of black hat SEO // @ By Yang Xiong Function findNum ($ str = '') {// retrieve all numbers in the string $ Str = trim ($ str ); If (empty ($ str) {return '';} $ Result = ''; For ($ I = 0; $ I <strlen ($ str); $ I ++ ){ If (is_numeric ($ str [$ I]) { $ Result. = $ str [$ I]; } } Return $ result; } $ The_lnum = strlen (findNum ($ q); // obtain the length of a numeric string If ($ the_lnum> 6) {// you can determine whether the length exceeds 6 to go directly to the search page. Header ("HTTP/1.1 301 Moved Permanently "); Header ("Location: http: //". $ _ SERVER ['HTTP _ host']. "/search. php "); Exit (); } ?> |