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.
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, huh? :-)
If you want to step in to help me cover the costs for running this website, that would be awesome. Just use this link to donate a cup of coffee ($5 USD for example). And please share the love and help others make use of this website. Thank you very much!
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.
How to: Determine which .NET Framework versions are installed
WsusPool keeps crashing: stops again and again
3 Important security measurements for Windows Server & IIS
Enable NTFS long paths in Windows Server 2016 by Group Policy
The WinCache effect: Save with object caching
Tips to speed up WordPress, serve gzip compressed static HTML files