URL Routing in Umbraco, how to redirect your website hostname in Umbraco from https://example.com to https://www.example.com.
By default, 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 is how to accomplish this.
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.
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, isn’t it? 🙂
Update 2018-10-30 about URLRewrite.config: @HotChilliCode mentioned on Twitter: since Umbraco version 7.6, the UrlRewriting dependency is removed and Umbraco no longer ships with it. Now you can use IIS URL Rewrite! You can read more about the changes in the Version Specific upgrades document: Version 7.6.0
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, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.
Install Windows Server Servicing Stack Updates (SSU) using PowerShell
Security baseline for Windows 10 v1903 and Windows Server v1903 – final release
Setting up Monit monitoring in Windows Subsystem for Linux WSL
How to verify SMBv1 is disabled in Windows and Windows Server