In this tutorial, you will learn how to configure your Umbraco powered website to force a www or a non-www Url policy. www, Vs non-www, is important in terms of SEO. Having multiple URLs that point to the same page can damage your sites SEO ranking within a search engine. Creating a rule that forces all traffic to use one policy, will give you some nice SEO mojo. If you want to learn how to apply a Url policy within your site, this is the tutorial for you 🔥🔥🔥

What Is The Difference Between WWW and non-WWW URLs?

In case you are new to this debate, the issue is centred around how the URLs for your web pages should be structured. Should all the links in your website be accessible using www, e.g. www.website .com, or should they only be accessible using the naked domain, e.g. website .com.

In terms of SEO, the difference between www vs non-www is pretty irrelevant. The choice between one or the other is a personal preference. The Google spider and ranking algorithm does not favour one over the other, so it is up to you to decide.

The most important thing is to pick a policy and stick to it. You need to stay consistent with your Url strategy from launch in order for your site to be ranked optimally. Failing to adopt a policy means that Google will treat www.website.com/news and website.com/news as two different pages and penalize your site for having duplicate content 😭

I personally recommend that you favour using a WWW approach as you get some minor technical benefits. Using a www policy allows more flexibility when you're messing around with DNS and setting cookies (Learn more here) 🤔

The WWW sub-domain was defined to represent a website service. When you use a naked domain policy, it does not explicitly tell a user which service they will be using. There are no technical benefits of using a Non-WWW policy, only a slightly shorter Url. When I make an architectural choice, it's usually based on terms of technical benefits. This is why I tend to stick with WWW policy, however, do what makes you happy 😊

How To Force www in Umbraco

Fixing the issue is done using a redirect rule. Allow access using one policy and create a redirect for all other requests. To enforce a WWW policy I recommend you use the IIS Url Rewrite module. The rule to force all URLs to include www is shown below:

Applying this rule within your web.config will mean all requests will be prefixed with www now 💥

The important thing to remember with the Url Rewrite module is that it needs to be installed on all of your servers. If you add this rule and try to run your site within IIS without the module installed, the whole site will break 😞

Using the IIS module is not the only way to enforce redirects within Umbraco. If you want a more detailed guide on Url rewriting in Umbraco, I recommend you read How To Set-up Page Redirects In Umbraco.

Conclusion

You now know how to force a www policy within a Umbraco site. This simple tweak takes a few minutes to apply, however, it can make your pages rank higher in the search engines so I recommend you apply this change within every project you work on. Happy Coding 🤘