Home > Backend Development > PHP Tutorial > PHP implements blocking black hat SEO search keywords and seo keywords_PHP tutorial

PHP implements blocking black hat SEO search keywords and seo keywords_PHP tutorial

WBOY
Release: 2016-07-13 09:57:03
Original
1156 people have browsed it

php implements blocking black hat SEO search keywords, seo keywords

I believe many webmasters have encountered this situation: the search function in the website is used by bad elements , by continuously searching for sensitive keywords in the search box on the site, a large number of spam search result pages with sensitive keywords on TITLE are generated (as shown below). Since Baiduspider has a limited crawl quota for each site, these spam search result pages will be included by Baidu, which will cause other meaningful pages not to be included due to quota issues. At the same time, Baidu's processing of spam pages may affect the normal performance of the website. Ranking.

For specific reference, please refer to Baidu’s official page http://zhanzhang.baidu.com/college/articleinfo?id=117

I will give you a method and my idea

The idea is like this. Those big guys who want to do this mostly still 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:

<&#63;php
 
//@功能 屏蔽掉黑帽SEO的搜索关键字
//@By 阳兄 
 
function findNum($str=''){ //取出字符串里面的所有数字
    $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));//获取数字字符串长度
if($the_lnum>6){ //判断长度是否超过6 超过则直接301到搜索页面
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://".$_SERVER['HTTP_HOST']."/search.php");
    exit();
}
&#63;>
Copy after login

The above is the entire content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984620.htmlTechArticlephp implements blocking black hat SEO search keywords, seo keywords I believe many webmasters have encountered this Situation: The search function on the website has been exploited by bad elements. By constantly searching in the search box on the website...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template