Scott Hanselman

Maintaining PermaLinks when moving from .Text to DasBlog

January 25, '06 Comments [6] Posted in DasBlog
Sponsored By

I believe very strongly in the concept of the PermaLink. They aren't TempLinks, they are meant to be as permanent as possible. When people want their hair done, they get perms, not temps.

When I moved this blog from Radio Userland back in September of 2003, I was worried that my 17 readers at the time wouldn't find the new blog. So, using Clemens' schema, I maintained my permalinks (mostly) via a funky redirect mechanism. If you should still find some old Radio urls and schmutz from my old blog, you'll be redirected to the old content that was imported here.

I've seen a number of folks migrate their content from .Text to DasBlog and there's a half-dozen utilities to do it, it's not too hard. What is more difficult/tricky is maintaining your old permalinks. Joshua Flanagan has contributed some stuff to the DasBlog project recently (that we'll make public later) but he also made some changes to the default web.config that can help folks maintain their URLs.

DasBlog has a very flexible RegularExpression-based URL Mapper (again, there's lots out there, not just DasBlog's) that will allow you to add matches, take them apart, and reassemble the results. Here's two for mapping .Text URLs to DasBlog. The end result is that requests for your old (non-existent) .Text pages are redirected to DasBlog.

This one should be used if you didn't use the old .Text PostID as the permalink GUID in DasBlog, so it's date-based. This is what Joshua added. Note that you'll likely already have the "<newtelligence.DasBlog.UrlMapper>" section, so just add the <add> element. Note also that I've split the regex up for formatting purposes, but the matchExpression should have NO whitespace.

  <!-- Translates
    FROM: /blog/archive/2004/07/27/194.aspx
    TO: /blog/default.aspx?date=2004-07-27
  -->
  <newtelligence.DasBlog.UrlMapper>
    <add matchExpression="(?&lt;basedir&gt;.*?)/archive/
                (?&lt;year&gt;\d{4})/(?&lt;month&gt;\d{2})/(?&lt;day&gt;\d{2})/
                (?&lt;postid&gt;\d+)\.aspx"
         mapTo="{basedir}/default.aspx?date={year}-{month}-{day}" />        
  </newtelligence.DasBlog.UrlMapper>

This one should be used if you DID use the old .Text PostID as the permalink GUID in DasBlog, which is my preferred mechanism. The GUIDs in DasBlog just need to be unique, and in this case we can toss the date info in the URL. 

   <!-- Translates
     FROM: /blog/archive/2004/07/27/194.aspx
     TO: /blog/permalink.aspx?guid=194
   -->
  <newtelligence.DasBlog.UrlMapper>
    <add matchExpression="(?&lt;basedir&gt;.*?)/archive/
                (?&lt;year&gt;\d{4})/(?&lt;month&gt;\d{2})/(?&lt;day&gt;\d{2})/
                (?&lt;postid&gt;\d+)\.aspx"
         mapTo="{basedir}/permalink.aspx?guid={postid}" />        
  </newtelligence.DasBlog.UrlMapper>

You can shape you URLs anyway you like. Maybe you brought your Radio content over like Jeff Sandquist, or if you've migrated content from other (homegrown) blogs to DasBlog.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.