Google is the most popular search engine. Being well ranked on Google is important for many sites to get nice organic traffic. Many sites try to serve content for Google crawler bots as fast as possible, so that increases the chances of the sites pages to rank well. In theory it is easy to detect when the Google bot is accessing a Web page. It is usually a matter of detecting the user agent string sent with requests from the Google bot crawler. However, there are crawlers and malicious bots that pretend to be the real Google bot faking its user agent string. This class provides a more robust way to detect whether a request is coming from Google bot or not. It just gets the HTTP client IP address and resolves its host name to verify if it really has one of the known Google bot domains.

Notable PHP package: PHP Detect Google Crawler

Universal Admin Interface



Tired of your sh***y back-office? Discover Forest, the Admin Interface for ambitious businesses. Get started now!

Rofl, a PHP package is considered Notable when it does something different that is worth noting.

If you have also written Notable packages, contribute them to the PHP Classes site to get your work more exposure.

If your notable package is innovative, you may also earn prizes and recognition in the PHP Innovation Award.

Now you can also win a Big elePHPant as one of the possible prizes you can win every month. Check the complete list of prizes here: List of prizes

Package

PHP Detect Google Crawler

Check if an access is from Google checking its IP

Moderator comment

Google is the most popular search engine. Being well ranked on Google is important for many sites to get nice organic traffic.

Many sites try to serve content for Google crawler bots as fast as possible, so that increases the chances of the sites pages to rank well.

In theory it is easy to detect when the Google bot is accessing a Web page. It is usually a matter of detecting the user agent string sent with requests from the Google bot crawler.

However, there are crawlers and malicious bots that pretend to be the real Google bot faking its user agent string.

This class provides a more robust way to detect whether a request is coming from Google bot or not.

It just gets the HTTP client IP address and resolves its host name to verify if it really has one of the known Google bot domains.

Author

G