Easy URL Rewritting using ASP.NET 4.0

FeedBurner had its uses in the past, in my case providing nice and detailed stats and ads inside RSS, although the lated didn't lasted much in my feeds as was pretty aggressive and noisy.

After Google bought it it kind of got stagnant and now is an undead product: serves just as an RSS stats proxy, but absolutely nothing else. So as I no longer care much about stats (plus they are low, the blog at Kartones.net with most readers has around 110 RSS subscribers), it was kind of an extra third-party tool that should go out.

Today, after months of delaying its removal, I've finally got rid of it. And it was actually quite easy once I read about ASP.NET 4.0 rewritting rules.

I won't get into details as there are lots of nice articles out there explaining its usage, and just provide a quick example of how to redirect an extensionless URL to another one:

Assuming you have configured the subdomain feeds.kartones.net as a normal ASP.NET 4.0 site, just add the following to your web.config file:

<rule name="kartonesblog" stopProcessing="true">
<match url="kartones$" />
<action type="Redirect" url="http://kartones.net/blogs/kartones/rss.aspx" redirectType="Permanent" />

This will redirect feeds.kartones.net/kartones to kartones.net/blogs/kartones/rss.aspx (the original source before setting up Feedburner) with a 301.

Of course this can also be used to do any operation, from removing extensions to switching them. IIS takes care of it and the old times of having to write custom handlers for basic rewrites are gone for good.

It is very tempting to always reinvent the wheel, like here writing a custom URL rewriting handler, but sometimes it is worth to spend 15 minutes reading if there is already a solid and proven solution, and in this case being a web server handler, it's even faster!


Posted by Kartones on 2014-05-04