Blog |Follow Nick on Twitter| About
 

Here's something cool to share.

My calcylator project is written in php, it's one of those "on-line tools" where users can create an account, log in, and can calculate personal profit & loss sheets for ebay.

Like most websites there are "log in" sections, now these pages need to be dealt with differently for search engines & users. Search engines will not be able to log in, but you may still want to deliver some content to them. Take my example, calcylator is running google adsense, and for adsense to work the googlebot (search engine) needs to be able to "see" some content, thinking this through, every time googlebot visited the log in or other protected pages all it would see is "access denied" error pages.

To target google with some "special" content, google kindly present themselves as google in their agent string. Now php even provide a simple tutorialon distinguishing user agent, so this is all I needed to do:

\ function find\_googlebot() { \# This is where we look for the googlebot \$user\_agent = \$\_SERVER["HTTP\_USER\_AGENT"]; if (preg\_match ("/[Gg][Oo][Oo][Gg][Ll][Ee]/", \$user\_agent )) { return true; } \#For debugging, uncomment this and the agent will appear in the source of the html. \#echo "\

 

 
Nick Bettison ©