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:

<system.webServer>
<rewrite>
<rules>
<rule name="kartonesblog" stopProcessing="true">
<match url="kartones$" />
<action type="Redirect" url="https://blog.kartones.net/syndication.rss" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>

This will redirect feeds.kartones.net/kartones to https://blog.kartones.net/syndication.rss (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!

Tags: Development

Easy URL Rewritting using ASP.NET 4.0 article, written by Kartones. Published on