TomDoepker.com / feed

301 Redirects

What do you do when you redevelop a website using a different coding language and you have a significant amount of links to your site that reference the old home page?

I recently upgraded a website to ASP.Net. The old site was not only popular (20-25K hits a month), it had been in existence for eight years, so it was no surprise that there were plenty of old links directed to the old home page, “default.php”.

After submitting the site changes to the search engines, I needed to account for folks who had specified the old home page file with their link to our site. I first added in URL mappings, but I have had less than stellar results with them. It wasn’t the “one hundred percent solution” I wanted.

My research pointed me to 301 redirects. Despite the fact that my sites are coded in C sharp, .Net is nice enough to let me use VB code I found as well. Since all that was really involved was creating a dummy page that would attract the old requests and redirect them appropriately, the two sets of code never see each other anyway.

There are three steps:

  1. Create a blank text document named the same as the page in question.
  2. Add the code below.
  3. Post the file to your website directory

Create a blank text document and name it the same as your offending page, in my case “default.php”.  Then include the code below, replacing my dummy location with the new one.

<%@ Language=”VBScript” %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader”Location”,”http://URLGoesHere/
%>

Add the new dummy file to your site’s directory and you’re all set. A further step would be to notify those sites that send you a lot of traffic about the update, but this allows you to handle your side quite efficiently.

Related posts

  1. Migrating SharePoint
  2. Dublin Core Metadata File
  3. Knowing the Answer
  4. Redesigning SharePoint
  5. The 2008 Digital Outlook Report from Avenue A | Razorfish