Quick Tip: Assign multiple hostnames to the one production domain correctly

I've got multiple hostnames (domain URLs) for the same production site eg www.mywebsite.com and www.my-website.com, plus the .co.uk versions, how will that work with your domain license?

uSkinned Member

In this scenario you should assign your main production domain (mywebsite.com) to your domain license file.

Any live website should only be served via a single domain. Any other domains (e.g. my-website.com or mywebsite.co.uk) you own that are pointing to your website should redirect to a single domain. This is very important for SEO as each domain is seen as a unique site by google so the more domains you have pointing to a site without a redirect to a main domain will negatively affect your SEO.

There are many approaches to setting your domain up however the easiest is to add your redirect rules to the web.config file of your website. In the following example mywebsite.com is the main domain of your website.

<rule name="Redirect to main domain" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="www.mywebsite.com" />
<add input="{HTTP_HOST}" pattern="www.my-website.com" />
<add input="{HTTP_HOST}" pattern="my-website.com" />
<action type="Redirect" url="http://mywebsite.com/{R:0}" />

If your website is served via https, change the action type above to:

<action type="Redirect" url="https://mywebsite.com/{R:0}" />

And then add the following rule:

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />

You will also need to add the unique IP address assigned to your SSL certificate to your conditions group since your website will also be accessible via this IP address:

<add input="{HTTP_HOST}" pattern="YOUR IP ADDRESS" />

Using this approach your website will always be served via mywebsite.com no matter what domains are pointing to your website and your domain license will always work.

comments powered by Disqus

Get started today

Join thousands of agencies, freelancers, enterprises & start ups worldwide who use uSkinned Umbraco themes to deliver results.

NEW Umbraco V8 themes!

We are now releasing our much anticipated Umbraco V8 themes.