Showing posts from December 22, 2004

Using Google to fix your 404 errors ( Part II )

A few weeks ago I wrote a small hack to use google to handle 404 errors. You can find that artcle here Using Google to handle website 404 errors Unfortunately even though it works, its not optimal. Here are the few drawbacks I noticed I was using Meta Redirects. Some bots didn't understand that very well Meta redirect generates a 302 (temporary move) instead of 301 (permanent) Some bots, browsers were refreshing the same page in an endless loop for some reason. So in frusteration I wrote another piece of code. This time I'm using google web-api to get my results internally, instead of forcing the user to go to the google website for the first best hit. Here is the code I'm using. Please remember to put in your google key in the right place before you try it out yourself. #!/usr/bin/perl use strict; use SOAP::Lite; my $request=$ENV{REQUEST_URI}; my $httphost=$ENV{HTTP_HOST}; my @found=(); my $foundtext=""; my $lookfor=&fix;($request); my $site="www.roya