How to get an email whenever Google visits your site

Tue, Jul 04, 2006

I was reading the article - "Ever wanted to know when google crawls your site (Ever wanted to know when google crawls your site)": via "Digg (Digg)": The article explains how you to send an email via a PHP Script when Google's spider (GoogleBot) visits your site. So, why not automate that for each and every page that is PHP powered.

To include the script on every page of your site, let us follow the following steps;

1. Modify your .htaccess file (create if you do not have one) to use the auto_prepend_file feature, it should have this line

php_value auto_prepend_file /home/

(a single line full absolute path to the autoappend.php on your server)

2. Create/Modify your autoappend.php (you are free to change the file name accordingly here and in the .htaccess file) to include the PHP script from ** (I've modified it slightly to have a clickable url when you get the mail);

But, my files extension is not PHP even though my server support PHP, how do I use this?

Well, you can use the same .htaccess to enable PHP for any file extension, you have to add this line

AddType application/x-httpd-php .html .htm

This will parse all files with the extension _html_ and _htm_ as PHP scripts.


* "Comprehensive guide to .htaccess (Comprehensive guide to .htaccess)":
* "PHP auto_append_file (PHP auto_append_file)":


# 2006 June 5 (10:00 am) - Be careful to set a filter for your email for this one. Now, I'm bombarded with "Googlebot Visit" mails!
# 2006 June 5 (02:00 pm) - This is perhaps a bad idea for a high traffic website. So, far I have received over 500 emails in just about 5 hours. I'm turning mine off.