Php: blocking black hat SEO search keywords _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php removes the black hat SEO search keywords. Php implements blocking of Black Hat SEO search keywords. I will give you a method. my idea is that the big guys who want to do this need to leave QQ or phone numbers for php to block black hats. 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

// @ 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

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 ();

}

?>

Let me give you a way. my train of thought is that most of the big guys who want to do this still need to leave QQ or phone numbers...

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.