Setting up multiple sites
Episerver CMS is multi-tenant, which means that a single running instance of CMS can host multiple websites. A multi-site setup is a solution where all sites share the same file structure on the web server and the same database for storage. Websites in a multi-site setup can share content assets, such as media and blocks. You can also run several parallel websites on the same server.
How it works
You have the following options to add new websites:
- Single-site setup lets you have just one CMS site mapped to one IIS instance in your installation. The IIS mapping is to a wild card or a specific host name. You can have several single sites with separate databases and code base on the same server. In this case, you would have a separate admin interface per site.
- Multi-site setup lets you have a single CMS site as a base (default site) and lets an administrator create additional new sites that share the same root page, database, and code base. The additional sites are automatically mapped and require no additional configuration (if the base site is mapped to wild card), or need manual configuration of the host name. When you work in a multi-site setup, you see all sites in the same interface. One reason to run a multi-site setup with specific host name mapping (that is, a different IIS instance per CMS site) is that you can use different application pools, which means that if one site goes down, the other sites continue to run.
Note: Even though CMS is multi-tenant, you can create separate IIS sites for separate CMS sites, using host headers to direct requests to the correct IIS site. The purpose of separating CMS sites into different IIS sites is to isolate sites in different processes from a fault tolerance perspective. This can be justified in some scenarios, even though memory usage may increase. When you run CMS in multiple processes, you have to configure the event system for inter-process events. As a best practice, always consider using load-balancing for fault tolerance instead of separating sites into IIS sites.
The following steps show how you set up multiple sites:
- IIS to configure host name mapping to websites, and to listen to any host name or specific host names
- Episerver CMS admin view to add a new website.
Multi-site setup requirements
- Each site must have a unique URL and start page in the content tree. You cannot nest start pages.
- A multi-site license defining the maximum number of sites frpo which the installation is licensed.
- IIS must be configured without host headers if you add new sites without making changes to the server (because that would require an administrator to manually add new host headers when you add new sites).
- All sites must have the same root path, which must be identical to what is configured in IIS. You cannot have one site as a virtual directory and another as an IIS site.
Adding a website from admin view
If you configure the IIS application to respond to any host name, then you can launch new sites from the CMS admin view without additional configuration. To define multiple sites, select Config tab > Manage Websites. You can add new sites and update existing sites. The website URL acts as a default URL to the website in cases where links are generated to the website.
You need only a start page and a URL for the new site. The URL and start page are stored in the database, and new sites are automatically provisioned. When you launch new sites, you can also configure them to use site-specific assets. For example, when you create a campaign website, editors may want to store assets in folders only available to that specific campaign site.
By default, one of the installed sites has the * (wild card) host mapping. You can also add additional hosts mappings, such as partner.examplesite.com or customer.examplesite.com, optionally bound to a specific language. You can also set up additional hosts that only should redirect to the main host or a specific host that should serve as the primary host for a specific language and the target for all redirects. Redirects only apply to content; to redirect a complete site, use settings in IIS instead.
Developing for multiple websites
Implementation code running under a web request, such as templates, does not need to take into account that multiple websites exist, because CMS automatically routes requests to the correct site. You can access the current site using the SiteDefinition.Current property (in the namespace EPiServer.Web).
A scenario where you may need to take into account that there are multiple sites is when running a scheduled job. Use the SiteDefinitionRepository class to list all sites and take appropriate action. You can use the SiteDefinition.Current property to access settings that are shared between sites when the current site cannot be determined. An example of such setting is the root page.
A possible misconception regarding authentication in multi-site setup is that logging out of one site while being logged in on other sites would also log you out from these websites. This is not the case because when you use Forms Authentication, by default, it stores authentication in a cookie per domain in the visitor's browser.
Last updated: Sep 21, 2015