Fixing my CS and .Text URL redirect issues
As some of you may have noticed, ever since I moved Community Server to the root of nino.net, I have had some outstanding URL issues. 1)my .Text redirect (forhttp://nino.net/blog/ -based URLs) has broken, and 2) all the http://nino.net/CS/blogs/nino -based URLs needed a redirect.
I spent a little time yesterday resolving both of these with one solution. I used a URL re-writer that I got from Dennis van der Stelt at http://bloggingabout.net/dennis/archive/2005/06/28/7408.aspx (it seems to have been started by Fritz Onion and been improved upon by several others). I found the original link on the Community Server blog forums. In addition to the very handy URL re-writing functionality, it also sends a permanent (HTTP 301) or temporary (HTTP 302) redirect (real swell for telling Google to update itself). These manifest as the first item in the <add> node (note that mine have a value of “true” for sending HTTP 301’s).
Here is the redirections section from my web.config:
<redirections type="Madgeek.Web.ConfigRedirections, Madgeek.RedirectModule">
<add permanent="true" ignoreCase="true" targetUrl="^/blog/(.*).aspx\??(.*)" destinationUrl="~/blogs/nino/$1.aspx" />
<add permanent="true" ignoreCase="true" targetUrl="^/CS/(.*)" destinationUrl="~/$1" />
</redirections>
The first redirect handles all URLs coming in for my .Text blog URL (e.g. http://nino.net/blog/archive/2005/02/09/552.aspx?Pending=true gets rewritten to http://nino.net/blogs/nino/archive/2005/02/09/552.aspx)
The second redirect handles all URLs having /CS/ in the path (e.g. http://nino.net/CS/blogs/nino/archive/2004/01/23/172.aspx gets rewritten as http://nino.net/blogs/nino/archive/2004/01/23/172.aspx)
I used RegexDesigner.NET from Chris Sells (I used to use The Regulator, but once I switched to running as non-admin it had issues) to verify my regex for the URL redirection along with a friendly reminder from my friend Mike L.
-Nino