How To Set-up Page Redirects In Umbraco

A company's website is kind of like a living entity; over time the CMS might change, pages might move around and even whole sections might get deleted. As part of this change, Url's for existing page will change. This has happened on pretty much every project that I've ever worked on. When it comes to creating re-direct in Umbraco we have several options. In today's tutorial, I'm going to cover some of the more frequently used techniques to create a re-direct in Umbraco.


Out of the box, Umbraco comes with 'UrlRewritingNet.UrlRewrite'. One word of caution before you use UrlRewritingNet.UrlRewrite is that historically, it has had some bad performance issues. I would recommend reading this article before you decide to use it. If you are only creating one or two redirects and you don't have a massive amount of traffic, then it is more than fit for purpose. To get started, in your website's webroot, have a look in 'Config' -> 'UrlRewriting.config'. This is the file that you will use to define the re-direct. Like most re-direct packages, the rules are configured by rules. For example,
	<add name="xmlsitemaprewrite"
		ignoreCase="true" />
The above rule, if you can't guess, transforms a request from to XmlSiteMap.

Url Rewrite

Url Rewrite is probably the most used re-direct tool. It's built by Microsoft and works directly in IIS. When you add a rule in IIS it adds it directly in the website's web.config. To get started with Url Rewrite, you need to download it from here. You will need to install it on all of your environments, so dev, test, staging and live. When the plug-in is installed, if you open IIS you should see the Url Rewrite option Umbraco_Redirects_1 If you click on this in the top right you should see an option called 'Add Rule(s)..' Umbraco_Redirects_2 When you click on 'Add Rules' you should see a screen that gives you a lot of options. In most instances you will just want to create a new inbound blank rule. Umbraco_Redirects_3 The next step in the process is actually defining the rule. Umbraco_Redirects_4 Like UrlRewritingNet.UrlRewrite you can define your Url's using Regular expression and get as complex as you want to. If, on the other hand, like me, in most cases you just want to create a simple redirect, then the process is pretty easy. Create a name for your rule, this can be anything you want. In the pattern add in the Url, minus the website domain, so would be sitemap.xml. In the action properties put the Url you want it to re-direct to, in my example I'm redirecting to which translates to XmlSitemap. Click 'Apply' in the top right and job done! If you look in your website's web.config you should now be able to see an entry similar to this:
                <rule name="Sitemap Re-direct">
                    <match url="sitemap.xml" />
                    <action type="Rewrite" url="XmlSitemap" />

If you prefer to work in your web.config you can just copy the section and change it to meet your needs. Simple!


In today's tutorial, we've covered two methods of creating re-directs within Umbraco. The first is the solution that comes out the box, UrlRewritingNet.UrlRewrite and Microsofts Url Rewrite. I personally wouldn't recommend using UrlRewritingNet.UrlRewrite. It might come with Umbraco but it's not as widely used or supported as Url Rewrite. Url Rewrite is used on thousands of servers, can be used in IIS and has good documentation. Url Rewrite is pretty easy to use, install it on all of your servers then either using the GUI or your websites web.config define your rules. Enjoy!

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + ''; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();