Php: shielding black hat SEO search keyword _ php instance

Source: Internet
Author: User
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.

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.