Believe that a lot of webmasters have encountered this situation: the site's search function by the bad molecules, through the search box in the site to continue to search for sensitive keywords, resulting in a large number of title with sensitive keywords on the garbage search results page (pictured below). Because the baiduspider of each site is limited to grab, so these garbage search results page is included in Baidu, will lead to other meaningful pages due to the quota problem is not included, at the same time may be due to Baidu processing spam pages and affect the normal ranking of the site.
Specific reference to the official Baidu page http://zhanzhang.baidu.com/college/articleinfo?id=117
I'll give you a way to do my thinking.
That's the way the big boys want to do this. Most of them still have to leave QQ or phone number
So I'm going to match the rules inside, find the number in the search, and then judge the length of the string to determine if it's a garbage search.
The code:
<?php
//@ function shielding off black hat seo search keywords
//@By Yang brother
function findnum ($str = ') {//Remove all digits inside 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))//Get the number string length
if ($the _lnum>6) {//Determine whether the length is over 6 or more than the direct 301 to the search page
header ("http/ 1.1 Moved Permanently ");
Header ("location:http://". $_server[' Http_host '). " /search.php ");
Exit ();
>
The above mentioned is the entire content of this article, I hope you can enjoy.