Wednesday 8 June 2016

Sitecore - Use subdomains for multi tenant or multi sites



If you want to share domain/host name  across your tenant sites in Sitecore. You can achieve it using below site definitions

<site  name="CountryGerman" virtualFolder="/german" physicalFolder="/german"
             rootPath="/sitecore/content/SiteGerman" hostName="yourhostname" targetHostName="yourhostname"
            startItem="/home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB"
            registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" language="en"
            enablePreview="true" enableWebEdit="true" enableDebugger="false" disableClientData="false" />            
 
<site  name="CountryIndia" virtualFolder="/india" physicalFolder="/india"
             rootPath="/sitecore/content/SiteIndia" hostName="yourhostname" targetHostName="yourhostname"
            startItem="/home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB"
            registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" language="en"
            enablePreview="true" enableWebEdit="true" enableDebugger="false" disableClientData="false" />            

 
<site  name="main" virtualFolder="/" physicalFolder="/"
             rootPath="/sitecore/content/yoursite" hostName="yourhostname" targetHostName="yourhostname"
            startItem="/home" database="web" domain="extranet" allowDebug="false" cacheHtml="true" htmlCacheSize="10MB"
            registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="5MB" filteredItemsCacheSize="2MB" language="en"
            enablePreview="true" enableWebEdit="true" enableDebugger="false" disableClientData="false" />            



With above site definitions 

  • http://yourhostname will get resolved to "main" site. 
  • http://yourhostname/india will get resolved to "CountryIndia" site.
  • http://yourhostname/german will get resolved to "CountryGerman" site. 

Important - The order of site definitions are very important here. the default site which uses the default domain(not sub domain) should always come at last.  

This approach we can use even if we need a device specific or langauge specfic subdomain for the same site.

No comments:

Post a Comment