Sitecore – 7 steps on how to enforce a website’s url from to

From time to time I have seen a request like this:

“I want all the links from my Sitecore website to start redirecting from to”

How do can this be done? There are actually a few ways you can do that. I’m showing you on this post only one which is easy and works just great.

Here are the 7 steps you can use to achieve that.

But before anything else we will need the very handy IIS Rewrite module in order for this to work. You can download it here.

There are two part that need to be properly configured:

  1. Sitecore’s site definition
  2. Create a rule using this module to take care of the redirection piece

Step 1 – Update the hostname attribute of the site definition to resolve both urls.

On your solution open the file SiteDefitition.config. By default it is located under App_Config/Include folder.

Ps: This assumes that you have removed the .example from the SiteDefinition.config. Also if you have a custom Sitedefinitions.config file this is where you should be updating this code.

Look for your site definition and update the hostName property of the site to resolve both to and To do that you can either add both entries  to the hostName separated by a “|” character or just use the “*” and let Sitecore handle the rest(most recommended).

Option 1: hostName=”|”

Option 2: hostName=”*”. This syntax means Sitecore will resolve anything that comes before, including “www.” which makes a hostname that it understands and resolves.

At this point Sitecore will resolve both urls and But IIS won’t.


Step 2 – Locate your site definition on IIS and open it’s bindings

On IIS you need to have a binding that resolves for the site. To do that open your website on IIS and click Bindings as shown bellow:



Step 3 – Create a binding that resolves

Click the Add button and set the hostname as and click OK. You will see a window like this:



Step 4 – Open the URL Rewrite section of your site.

On the IIS section of your website definition look for the URL  Rewrite button and double click it.


Step 5 – Click on Add Rules(s)


Step 6 – Create a Url Rewrite canonical url

On the Add Rule(s) window select the Canonical domain name section as shown bellow:


Step 7 – Select the primary host name

Make sure the hostname is selected. After that click OK.



That’s it! Now all the traffic on your Sitecore instance coming from will get redirected to





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s