I want to configure my instance of Sitecore to respond with different sites at different urls. How can I do this?
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.
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:
- Configure DNS appropriately.
- Add a binding in IIS for each hostname.
- Copy or rename the config file
App_Config/Include/SiteDefinition.config.example
toApp_Config/Include/SiteDefinition.config
- 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
-
1Agree. 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. – Yogesh Patel Sep 20 '16 at 18:50
-
1You 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 Sep 20 '16 at 20:10
-
@bmyers the file I reference is a patch file that by default comes with a .example extension in sitecore – Kyle Trauberman Sep 20 '16 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 Sep 20 '16 at 21:23
-
I updated my answer to include the step of copying or renaming the example file to clarify that. – Kyle Trauberman Sep 20 '16 at 21:38
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 it's 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.
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
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
There is a Sitemap XML module available on the Sitecore market place (https://marketplace.sitecore.net/Modules/Sitemap_XML.aspx), this will need to be assessed to ensure it works correctly in Sitecore 8
There is a Robots.txt module available on the Sitecore market place (https://sitecoreclimber.wordpress.com/2014/07/27/sitecore-multisite-robots-txt/), this will need to be assessed to ensure it works correctly with Sitecore 8
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:
-
+1 these are all valid things to be aware of in addition to configuring routing, etc. – Kyle Trauberman Sep 21 '16 at 17:48
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]