Author Topic: Googlebot code  (Read 6044 times)

Offline hidden

  • Sami
  • Administrator
  • Senior Member
  • *****
  • Posts: 5924
  • Not a geek. Just a Nerd.
    • CSB Tutorials
Googlebot code
« on: January 19, 2009, 12:16:18 PM »
Want to know when Google is visiting your website?
TURTLE gave us this information last year and thought it would be a good thing to share:



The googlebot code for the bottom of a page is

Code: [Select]
<?php
if(eregi("googlebot",$HTTP_USER_AGENT))
{
if (
$QUERY_STRING != "")
 {
$url "http://".$SERVER_NAME.$PHP_SELF.'?'.$QUERY_STRING;}
else
 {
$url "http://".$SERVER_NAME.$PHP_SELF;}
$today date("F j, Y, g:i a");
mail("googlescan@mydomain.com""Googlebot detected on http://$SERVER_NAME""$today - Google crawled $url");
}
?>



If your pages end in .htm or .html
be sure to add

AddHandler application/x-httpd-php .htm .html .shtml
to your .htaccess file.

===================
googlescan@mydomain.com
Would of course need to be changed to YOUR email address.  I added an email address to my domain specifically for google.   ONLY purpose for that email addy is for google. All other emails that would come into that addy would be dumped.


About the .htaccess file:

This file is put into your root directory and directs traffic in many ways...permanent redirect, passwords, lots of things. Read about .htaccess files here.  That's one of the best tutorials on the subject I have seen! 

But as that site says:
Some sites do not allow use of htaccess files, since depending on what they are doing, they can slow down a server overloaded with domains if they are all using htaccess files. I can't stress this enough: You need to make sure you are allowed to use htaccess before you actually use it. Some things that htaccess can do can compromise a server configuration that has been specifically setup by the admin, so don't get in trouble.

.htaccess is the file extension. It is not file.htaccess or somepage.htaccess, it is simply named .htaccess

If you are allowed to make an .htaccess file, and do not already have one (some website management software like cpanel will make on when doing passwords, etc) you can make one simply:

Open Notepad
Paste this in:    AddHandler application/x-httpd-php .htm .html .shtml
File Save As:     .htaccess
Then upload that file to your website.
Done.

-Samantha
TNG: "Sometimes, you can make no mistakes, do everything right, and still lose" - Capt Picard to Data
(:turtle: In memory of Turtle: May 22, 1944 - Nov 24, 2007  GURU, mentor, and really nice guy! :turtleleft: )

Offline hidden

  • Expert Member
  • Senior Member
  • *****
  • Posts: 1348
  • LaughLots
Re: Googlebot code
« Reply #1 on: January 20, 2009, 04:32:57 AM »
Cool  8)

:thankyousign: Sami for the update.
:dogwalksm: Ed