Redirect Blogengine Links to WordPress (running on a Rackspace Cloud)

Problem

I used to have a web server running IIS and BlogEngine.  When people come to my new site looking for an article they will get a nasty error.  For one the site is now PHP.  I wanted to remap all the files from the old URL’s to the new URL’s.

Old URL
http://www.devclarity.com/blog/post/topic.aspx

New URL
http://www.devclarity.com/index.php?s=topic

I figured I would just put a redirect in .htaccess, but little did I know that the web server sees the .aspx extension of the old URL and processes it on the IIS server.  Thanks a lot Rackspace Cloud :-)

Solution

I created a Web.Config file to send all errors to a page called Redirect.aspx.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.web>
		<customErrors defaultRedirect="redirect.aspx" mode="On">   
		    <error statusCode="500" redirect="redirect.aspx" />
		    <error statusCode="404" redirect="redirect.aspx" />
		    <error statusCode="403" redirect="redirect.aspx" /> 
		</customErrors>
    </system.web>
</configuration>
Then, redirect.aspx takes the URL and modifies the aspx extension to a html one and redirects the new link back to the page.
<%
	Dim ASPXPath as String
	
	ASPXPath = Request.QueryString("aspxerrorpath") 
	ASPXPath = ASPXPath.Replace("aspx", "html").replace("-", "+")
%>
<html>
<body>
	<h3>Please wait, your content has moved</h3>
	
	<script>
		window.location='<%=ASPXPath%>';
	</script>
</body>
</html>

Old URL:
http://www.devclarity.com/blog/post/topic.aspx

New URL:
http://www.devclarity.com/blog/post/topic.html

So now, the only thing was setting up the .htaccess file to handle the old url.  What this rule does, is it takes the topic out of the passed URL and reroutes it to the WordPress search engine.
RewriteRule ^blog/post/([\w-\+]+)\.html$ /index.php?s=$1 [R=permanent,L]

Result

http://www.devclarity.com/blog/post/Backup-Mover.aspx now takes you to the remapped Backup Mover page on the WordPress site.

(Of course, this post is new so if you use the old backup-mover link you will see this page first with the backup mover article under it :-( )