PHP allows you to display different contents to visitors and crawlers. To improve the user experience of web pages, we often do some unfriendly things about search engines, but in some cases this is not irrecoverable, in order to improve the user experience of web pages, we often do some unfriendly things to search engines, but in some cases this is not irretrievable, you can provide a good user experience and SEO by displaying different content to natural persons and search engine robots.
I have heard that this method violates some search engine operating principles and may be penalized by various search engines or even deleted from websites. so I have just removed this process until I confirm that it is not cheating. if you have the courage to continue using the service, you are at your own risk.
The homepage and archive page of this blog displays articles in the form of a list. only the content of the article is loaded when a visitor clicks to expand the article. because the content of the article contains a lot of text and images, it requires a lot of loading time and traffic. displaying webpages to visitors as soon as possible can retain a large number of visitors. for mobile phone users, loading time and traffic are more important.
In general, the homepage of a website is the most visited page by the search engine. you should try to show meaningful content to it, but to display the article in the form of a list, visitors and search engines can only obtain the title information of an article. the content or abstract of the article (especially the first sentence) is extremely important for SEO, so we should try to send the content to crawlers.
Well, we can use the User Agent to determine whether the visitor is a crawler. If yes, the document will be displayed in the general form; otherwise, the document list will be displayed in the form of a list. you can use the following PHP method to determine whether a crawler is used:
Copy to ClipboardReference: [www.bkjia.com] function is_crawler (){
$ UserAgent = strtolower ($ _ SERVER ['http _ USER_AGENT ']);
$ Spiders = array (
'Googlebot ', // Google crawler
'Baidider Ider ', // Baidu crawler
'Yahoo! Slurp ', // Yahoo crawler
'Yodaobot ', // Youdao crawler
'Msnbot '// Bing crawler
// More crawler keywords
);
Foreach ($ spiders as $ spider ){
$ Spider = strtolower ($ spider );
If (strpos ($ userAgent, $ spider )! = False ){
Return true;
}
}
Return false;
}
This is my method. crawlers sort access comments from high to low, and then use the following method to display different content to crawlers and natural persons.
Sorry, we often do something unfriendly to the search engine, but in some cases this is not irretrievable, you can go to the natural person and the search engine...