July 24, 2004
301 redirects, custom 404 and .htaccess
I managed to get the Deer Park Hotel website swapped over to my new version last night. I really need to get and keep good page rank for this site so I have also implemented things I normally dont bother with (*shame!*) - the custom 404 and permanenet redirects, better known as 301 redirect.
My redesign of the Deer Park site was in a sub-directory newsite for long enough that Yahoo and Google managed to index it - mainly due to me posting the URL to various chat boards looking for testing on Mac browsers. I didnt put in a robots.txt file to close off the newsite directory to search engines - my bad.
Anyway, to keep those indexes pointing at my creation I need to create some 301 redirects. Easy enough. I crank up my text editor, open (or create) the .htaccess file and start with:
redirect 301 /newsite/index.html http://www.deerpark-hotel.ie/index.html
This basically tells the server that should someone come looking for the file in the directory /newsite/index.html that it has moved to http://www.deerpark-hotel.ie/index.html. Try it and see. All I had to do then was create a similar entry for each and every page on the site - yawn - I briefly - briefly! - considered including the images. I suppose I could write a Perl script that would create a 301 redirect list for me for all the contents of the newsite directory but I'll do it right next time and include a robots.txt file :)
Something I always wanted to do was to include a custom 404 error page. Not really up there with sky diving and extreme sports I know, but I am a simple man! Again this is easy to do. Fire up your text editor with the .htaccess file again and enter the following line:
ErrorDocument 404 http://www.deerpark-hotel.ie/errorpages/custom404.html
The save it and you're done! Now any time the server returns a 404 error it will display the page above. It is possible to add all sorts of bells and whistles to this to try and suggest a page to the visitor. I might add this when I have time.
The final version (for now...) of the Deer Park Hotel website can be found at:
And yes the link above is there to try and gain a little extra pagerank - I'm mercenary, so what!
Posted by dottie at 2:05 PM