4

I am trying to create a subdomain for my current site in Sitecore that is simply a mirror or my primary site. The reason for this is that our partner CDN provider is requiring us to host a copy of our main site on a "www-origin" subdomain.

To expand on what our goal is a bit; We want to have 2 sites www.example.com and www-origin.example.com. Both of these sites should have the same content, structure, languages, forms and overall should be a perfect mirror of our current site. We have made some changes that have enabled the www-origin subdomain but it currently adds the root directory into the url which is not done for our main site.

The only changes we have made thus far are to the sitecore.config file. We have not created any site or structure for the subdomain in the Sitecore CMS as we don't want it to be any different from the main site. The config file changes we have made are outlined below.

<event name="publish:end">
  <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel"
           method="ClearCache">
    <sites hint="list">
      <site>origin</site>
      <site>website</site>
    </sites>
  </handler>
  <handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel"
           method="ClearCache" />
</event>
<event name="publish:end:remote">
  <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel"
           method="ClearCache">
    <sites hint="list">
      <site>origin</site>
      <site>website</site>
    </sites>
  </handler>
  <handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel"
           method="ClearCache" />
</event>


<sites>
  <site name="origin" scheme="https" hostName="www-origin.example.com"
        targetHostName="www-origin.example.com" enableTracking="true" virtualFolder="/"
        physicalFolder="/" rootPath="/sitecore/content" startItem="/home"
        database="example" domain="extranet" allowDebug="true"
        cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0"
        viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB"
        enablePreview="true" enableWebEdit="true" enableDebugger="true"
        disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" />
  <site name="website" scheme="https" hostName="example.com"
        targetHostName="example.com" enableTracking="true" virtualFolder="/"
        physicalFolder="/" rootPath="/sitecore/content" startItem="/home"
        database="example" domain="extranet" allowDebug="true"
        cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0"
        viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB"
        enablePreview="true" enableWebEdit="true" enableDebugger="true"
        disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" />
</sites>


<cacheSizes>
  <sites>
    <website>
      <html>50MB</html>
      <registry>0</registry>
      <viewState>0</viewState>
      <xsl>25MB</xsl>
    </website>
    <origin>
      <html>50MB</html>
      <registry>0</registry>
      <viewState>0</viewState>
      <xsl>25MB</xsl>
    </origin>
  </sites>
</cacheSizes>

What do I still need to do in order make the www-origin subdomain match the example.com domain but without the root directory being added to the url by Sitecore? We are currently on Sitecore version 8.1.

1 Answer 1

4

I think this might help solve the problem assuming the base website is working as expected. If the mirrored site can be the exact same site (same content and exact same items) which it seems like your example is then you can use the following:

<site name="website" scheme="https" hostName="example.com|www-origin.example.com"
        targetHostName="example.com" enableTracking="true" virtualFolder="/"
        physicalFolder="/" rootPath="/sitecore/content" startItem="/home"
        database="example" domain="extranet" allowDebug="true"
        cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0"
        viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB"
        enablePreview="true" enableWebEdit="true" enableDebugger="true"
        disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" />

Notice the hostname attribute: hostName="example.com|www-origin.example.com". Making these two hostnames map to the same exact site definition should force them to act the same assuming there is no custom code doing something based on the domain being used for a request.

The links while navigating to the site with the www-origin.example.com url that should link to the current site (item links to the current site) will resolve using the targetHostName. If that will cause an issue for your use case then this will not work out. For the definition of the targetHostName attribute see this link. For the definition of the hostname attribute see this link.

2
  • Up-voted as this does work but, as outlined in the answer, it redirects some links to the primary site so it would not work for what I will need.
    – KHeaney
    Commented Aug 23, 2017 at 14:54
  • @KHeaney can you go to baseUrl/sitecore/admin/showconfig.aspx and verify there is nothing added to one of your site nodes by a patch config? If that is indeed the case try to keep them in sync by using the inherits attribute.
    – Teeknow
    Commented Aug 23, 2017 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.