Maintaining PermaLinks when moving from .Text to DasBlog
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="(?<basedir>.*?)/archive/
(?<year>\d{4})/(?<month>\d{2})/(?<day>\d{2})/
(?<postid>\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="(?<basedir>.*?)/archive/
(?<year>\d{4})/(?<month>\d{2})/(?<day>\d{2})/
(?<postid>\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.
About Newsletter
That's a one line change if it bothers you. Let me know.
In PermaLink.aspx.cs, look at the first 6 lines of LoadEntries(). If an entry wasn't found by this point, we 404 them. Change that section before the "return null" to a Response.Redirect and you should be in business.
Comments are closed.
One thing that has bugged me for a while (but not enough to start digging into source code) is that (presumably) the url re-writer mechanism does not re-direct me to the home page when a url does not exist. Try this:
http://www.hanselman.com/blog/DoesNotExist.aspx
Interestingly you have not set up a custom 404.html (tut, tut, tut, finger wagging etc):
http://www.hanselman.com/blog/DoesNotExist.html
I did and it works for non aspx pages + I am sure it worked with .Text:
http://www.dotnetworkaholic.com/DoesNotExist.html
http://www.dotnetworkaholic.com/DoesNotExist.aspx (does not forward to home page)
Am I missing something, or is this an issue inside DasBlog? Yes I know I should get it from CVS and start digging… when this home DIY, .Net community work, 6 minute mile etc are all done I’ll get there :)