PHP to achieve the mask off black hat seo search keyword _php instance

Source: Internet
Author: User
Tags strlen

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.