Importancy of the '301' status code

The glorious 301 (three-oh-one) status code can save you alot of trouble when upgrading a website. Especially if you care about google ranks, and assisting your visitors...

During the upgrade to vikkel.dk / vikkel.com I had to do a little 301 implementing myself. See, the old blog-system was built in old-fashioned asp (vbscript), and this new glorious blogging tool is written in asp.net (c#).

The problem at hand:
  • Old (filename.asp) URL's are becoming obsolete.
  • New (newfilename.aspx) URL's are entering the stage - but nobody knows about it (especially not the global search engines!).

In order to cure these 2 issues, i had to do the following:
Strip the old scripts for all code, and enter new, valid, 301 redirection code.

Mainly the "entry.asp" file, which displayed all the posts (using old-fashioned querystring values) had to be updated.

Heres the content of that entry.asp file now:
301 solution

As you can see it actually captures any of the incoming article links, and diverts them to their new URL. Piece of cake!
If i had not done this then right now all links coming from google (or other search engines, including bookmarks), would be pointing at something obsolete. And maybe even worse - at a non existing file due to deletion.


Regardless of what server/solution change you do - ALWAYS make sure you use a 301 redirect from old files to new ones. Otherwise you might as well put a "Sorry, we're closed" sign at your frontpage. Not sure how to do it in your IIS environment..? Let me know, and I will write some more guides.

I've also been doing this at work when we changed CMS to "Sitecore". Even though it meant cleaning 300+ files and making them point at the new version. Boring, but worthwhile and crucial.

Print | posted on Thursday, February 01, 2007 7:34 PM