Umbraco: Route example.com to www.example.com

URL Routing in Umbraco, redirect website hostname in Umbraco (from https://example.com to https://www.example.com). Umbraco listens to both http://example.com and http://www.example.com. This is not good for your Google ranking and SEO, since this will be seen as duplicate content. Fortunately, it is pretty easy to redirect your website to it’s www variant. Here you’ll learn how to accomplish this.

URL Routing in Umbraco: how Umbraco uses rewrites #

Umbraco uses it’s own MVC URLRewrite module. Therefore, you can’t use IIS URLRewrite (web.config) to redirect the website to it’s www address.

Umbraco URLRewrite.config
To redirect your example.com domain to its www.example.com variant, you have to add a redirect to your Umbraco configuration file Config/UrlRewrite.config. Simply add the following redirect:

<add name="domain_to_www"   
  redirect="Domain"  
  ignoreCase="true"
  rewriteUrlParameter="IncludeQueryStringForRewrite"
  virtualUrl="http://example.com/(.*)"
  redirectMode="Permanent"
  destinationUrl="http://www.example.com/$1"
/>

That’s it… Easy, huh? :-)


Please Support Saotn.org

Each post on Sysadmins of the North takes a significant amount of time to research, write, and edit. Therefore, your donation helps a lot! For example, a donation of $3 U.S. buys me a cup of coffee, and as you know: things jsut work better with coffee. A $10 U.S. donation buys me one month of web hosting (yes, hosting costs money). But seriously, thank you for any amount. Much appreciated!

I thought you might find this interesting:   Convert .htaccess to web.config

Please donate to support this site if you found a post interesting or if it helped you solve a problem. Thanks! (Tip: no Paypal account required)

If you appreciated this post, then please donate using this Paypal button


Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, websites & optimization.

Leave a Reply

Be the First to Comment!

Hi! Join the discussion, leave a reply!