Wednesday, January 11, 2012

Defining Multiple Sites in Sitecore's Host File

Just discovered an odd little fact about how the sites/site node works in Web.config when defining multiple sites. There is an implicit wildcard functionality, so that if you have two host names, such as "Sitecore65" and "Sitecore65b", a site with hostname="sitecore65" will match both.   So if you want "Sitecore65B" to go to a different home item form Sitecore65, you have to put this entry first in Web.config:


       <site name="website2" hostname="sitecore65b" virtualFolder="/" physicalFolder="/" ...
       <site name="website" hostname="sitecore65" virtualFolder="/" physicalFolder="/" ...
Sitecore's multisite documentation mentions wildcard functionality, but from the way it is stated, I assumed this was explicitly specified with an asterisk:
Sitecore compares the hostName attribute (which may include wildcards) with the incoming URL
Oh well, you known what they say about assuming things...

No comments:

Post a Comment