11

I want to configure my instance of Sitecore to respond with different sites at different urls. How can I do this?

6 Answers 6

20

This is an addition to Kyles answer. While you can do the full site definition for each site, it quickly becomes cumbersome and really for most of the settings you have the same values.

So you can use property inheritance in the patch file. For example if we have 4 sites, we can create the first one with fill definitions, but for the others, we can just change the values that are different, like this:

<sites>
  <site name="site1" virtualFolder="/sitecore/admin" 
    physicalFolder="/sitecore/admin" enableAnalytics="false" 
    domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>

  <site name="site2" inherits="site1" />
  <site name="site3" inherits="site1" domain="extranet" />
  <site name="site4" inherits="site1" enableAnalytics="true" />
  <!-- etc etc ... -->
</sites>

Notice the inherits attribute in the other site nodes. This makes it nice and simple to add new site definitions.

The rest is covered in the answer by Kyle.

3
  • I did not know this! Thank you Richard! Commented Sep 21, 2016 at 13:39
  • Same here. I was unaware of the inherits attribute. Commented Sep 22, 2016 at 19:58
  • I was going to add this. Good call :)
    – Teeknow
    Commented Aug 10, 2017 at 4:03
18

You can configure Sitecore to respond to requests with different home nodes based on the url.

To do so, you need to perform the following steps:

  1. Configure DNS appropriately.
  2. Add a binding in IIS for each hostname.
  3. Copy or rename the config file App_Config/Include/SiteDefinition.config.example to App_Config/Include/SiteDefinition.config
  4. Modify the config file from step 3 with a new <Site> node for each site.

For example:

<!-- this entry will respond to http://site1.hostname.com/mysite with the /Sitecore/sites/mysite/home node -->
    <site name="SiteName" patch:before="site[@name='website']"
        hostName="Site1.hostname.com"
            virtualFolder="/mysite"
            physicalFolder="/"
            rootPath="/sitecore/sites/mysite"
            startItem="/home"
            database="web"
            domain="extranet"
            allowDebug="true"
            cacheHtml="true"
            htmlCacheSize="50MB"
            enablePreview="true"
            enableWebEdit="true"
            enableDebugger="true"
            disableClientData="false"/>

For more information see: https://sdn.sitecore.net/Articles/Administration/Configuring%20Multiple%20Sites/Configuring%20Sites%20in%20web,-d-,config%20File.aspx

5
  • 1
    Agree. Few additional points to remember, very useful to avoid silly mistakes - 1. Make sure to add sites before "scheduler" site or before the "website". 2. Multiple domains can be mapped by using '|' seperator in host attribute (instead of creating multiple sites for multiple domains). 3. Try to avoid using a host name which is a substring of another site host name. Like, avoid case where site-A using sitecore.net, and site-B using www.sitecore.net. As, SiteResolver uses wildcard parser for parsing host. Commented Sep 20, 2016 at 18:50
  • 1
    You should avoid modifying any of the Sitecore configuration files directly. Sitecore has an option to use patch configuration files instead. Modifying the Sitecore configuration files directly makes upgrades much more involved.
    – bmyers
    Commented Sep 20, 2016 at 20:10
  • @bmyers the file I reference is a patch file that by default comes with a .example extension in sitecore Commented Sep 20, 2016 at 20:34
  • That's right, I forgot that is a provided .example file. I added an answer previously since it isn't obvious in this answer that it is a patch file or that it comes from that .example file.
    – bmyers
    Commented Sep 20, 2016 at 21:23
  • I updated my answer to include the step of copying or renaming the example file to clarify that. Commented Sep 20, 2016 at 21:38
9

This is one of those questions where there are multiple answers available. The answer above by Kyle Trauberman is the default, configuration way that Sitecore provides to do multiple sites. It has its pro's and con's.

There are also a handful of modules on the Sitecore Marketplace, such as Dynamic Sites Manager, that provide the ability to create sites within Sitecore itself.

Dynamic Sites Manager

In addition, available as an extra module purchase to your Sitecore license, the Sitecore Experience Accelerator (SxA), provides built-in multi-tenant, multi-site capabilities within Sitecore, and not bound by configuration files.

My personal preference is using Dynamic Sites Manager, but I'll disclose that I wrote it. So I may be a bit biased. For more information about this tool, you can visit SitecoreHacker.com

6

As the other comments have mentioned the hostnames in the config need configuring however alongside that there are quite a lot of things to consider for multi-site in Sitecore and the difficulty of getting it to work depends on if it was considered in the initial build or not.

I'll jot down some bits and pieces to consider, especially in the scenario where this is not a greenfield build.

Global Settings

Have an area of the tree for true "Global settings" across all sites in Sitecore and a separate one for each of the specific global settings, for example site logo etc.

Shared Components

Do you need global components and site specific components? If so split component folders to global and site specific too

Relative data sources

Check to see if any data sources need to be changed to be relative to the site you're in, useful when referencing site specific global settings.

SEO

For SEO you need to consider a separate robots.txt and sitemap.xml for each site

Search

Ensure that Sitecore only searches over each individual site not all microsites - details on this are here (for SOLR)

404 and 500 pages

Do these need to be different for each site? In which case this will need to be handled; pretty sure we used a module off the marketplace for this but I can't remember which; I'll update this when I track it down.

Media library

Organise the media library so there are different areas for each site

Security and workflow

Add security and workflow to lock down roles to access the correct areas of the site

Web forms for marketers

We didn't need to do this as the micro-sites didn't require forms however details are here:

https://doc.sitecore.net/web_forms_for_marketers/setting_up_web_forms/installing/multisite_implementation_with_web_forms

1
  • +1 these are all valid things to be aware of in addition to configuring routing, etc. Commented Sep 21, 2016 at 17:48
2

Configure the site node in IIS to add the new host name binding.

Create a patch file to patch in a site node to the /sitecore/sites configuration section.

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>
      <site name="site" 
            patch:after="site[@name='modules_website']"
            targetHostName="site.hostname.com"
            database="master"
            virtualFolder="/"
            physicalFolder="/"
            rootPath="/sitecore/content/site"
            startItem="/Home"
            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"
            enableItemLanguageFallback="true" />
    </sites>
  </sitecore>
</configuration>

Change the values for targetHostName, rootPath and startItem to match for the site you are configuring.

Place the patch config in App_Config/Include/[folderNamePerStandards]

0

Follow below steps :-

  1. Create different folder items for each sites pages

  2. Add/enable the SiteDefinition.config file and add site entry,

     <site name="MyOnline" patch:before="site[@name='website']" hostname="mvcsitecoredemo" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content/MyOnline" startItem="/index" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" language="en" />
    
  3. Add separate binding in IIS for each host name

  4. Add host entry in hosts file (if it is local site)

Please avoid common mistakes like - assigning attribute @name='website' for multiple sites while defining the patch but it should be different for each site otherwise second site will show first sites pages only.

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.