Umbraco v6.
I have one Umbraco installation with two sites. Second site was added under the "Culture and Hostnames" options.
Under Site 1 Culture and Hostnames is empty but controlled by IIS. Under Site 2 Culture and Hostnames has http://site2.com
When a user navigates to http://site1.com they reach site 1.
When a user navigates to http://site2.com they reach site 2.
So all works as expected.
Is there anyway to add canonical domains so that
http://site2.com changes to http://www.site2.com
http://site1.com changes to http://www.site1.com
Note the www for each URL.
Remember there is 1 IIS site 1 Umbraco installation and 2 sites in this 1 installation which point to two different websites.
Is this possible to keep the functionality as is but with the changes mentioned above?
You can do this with the IIS Rewrite module. http://www.iis.net/downloads/microsoft/url-rewrite
You'll just need to write regular expressions to target each of your domains.
e.g (untested).
<rule name="Redirect From Site1" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^site1.com$" />
</conditions>
<action type="Redirect" url="http://www.site1.com/{R:0}" />
</rule>
<rule name="Redirect From Site2" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^site2.com$" />
</conditions>
<action type="Redirect" url="http://www.site2.com/{R:0}" />
</rule>