php blocks black hat SEO search keywords
I will give you a method and my idea
The idea is like this. Most of the big guys who want to do this have to leave their QQ or phone number
Then I will match the rules inside, find out the numbers in the search, and then judge the length of the number string, and then judge whether it is a junk search
Provide the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
//@功能 屏蔽掉黑帽SEO的搜索关键字
//@By 阳兄
function findNum($str=''){ //取出字符串里面的所有数字
$str=trim($str);
if(empty($str)){return '';}
$result='';
for($i=0;$i
if(is_numeric($str[$i])){
$result.=$str[$i];
}
}
return $result;
}
$the_lnum=strlen(findNum($q));//获取数字字符串长度
if($the_lnum>6){ //判断长度是否超过6 超过则直接301到搜索页面
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://".$_SERVER['HTTP_HOST']."/search.php");
exit();
}
?>
|
1
2
3
4
5
6
7
8
9
10
11
1213
14
15
16
17
18
19
20
21
22
23
|
<🎜> <🎜>
<🎜>//@Function to block black hat SEO search keywords<🎜>
<🎜>//@By Brother Yang<🎜>
<🎜> <🎜>
<🎜>function findNum($str=''){ //Get all the numbers in the string<🎜>
<🎜>$str=trim($str);<🎜>
<🎜>if(empty($str)){return '';}<🎜>
<🎜>$result='';<🎜>
<🎜>for($i=0;$i
<🎜>if(is_numeric($str[$i])){<🎜>
<🎜>$result.=$str[$i];<🎜>
<🎜>}<🎜>
<🎜>}<🎜>
<🎜>return $result;<🎜>
<🎜>}<🎜>
<🎜>$the_lnum=strlen(findNum($q));//Get the length of the numeric string<🎜>
<🎜>if($the_lnum>6){ //Determine whether the length exceeds 6. If it exceeds 6, directly 301 to the search page
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://".$_SERVER['HTTP_HOST']."/search.php");
exit();
}
?>
|
http://www.bkjia.com/PHPjc/984500.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984500.htmlTechArticlephp implements blocking search keywords of black hat SEO. I will give you a method. My ideas are like this. Most of the big guys who want to do this have to leave their QQ or phone numbers...