This article mainly introduces related information about how php can block the search keywords of Black Hat SEO. we recommend this article to you. if you need it, you can refer to it. I believe that many webmasters have encountered this situation: the search function in the website is used by undesirable elements and sensitive keywords are constantly searched in the search box of the website, generate a large number of junk search results (such as) with sensitive keywords on the TITLE ). Because baidusphas a limited amount of crawlers for each site, these junk search result pages are indexed by Baidu, which will cause other meaningful pages not to be indexed due to quota issues, at the same time, the normal ranking of websites may be affected because Baidu processes junk pages.
Specific reference Baidu official page http://zhanzhang.baidu.com/college/articleinfo? Id = 117
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:
<? Php // @ function blocks the black hat SEO search keyword // @ By Yang brother function findNum ($ str = '') {// retrieve all digits in the string $ str = trim ($ str); if (empty ($ str) {return '';} $ result = ''; for ($ I = 0; $ I
6) {// Determine whether the length exceeds 6. then, the system will directly go to the header ("HTTP/301 1.1 Moved Permanently") of the search page. header ("Location: http ://". $ _ SERVER ['http _ host']. "/search. php "); exit () ;}?>
The above is all the content of this article. I hope you will like it.