EPiServer CMS is multi-tenant, that 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. It is also possible to run several parallel websites on the same server.
How it works
You have the following options to add new websites:
- Single-site setup allows you to just have one CMS sitemapped to one IIS instance in your installation. The IIS mapping is either with wild card or to a specific host name. It is possible to have several single sites with separate databases and code base on the same server and you would then have a separate admin interface per site.
- Multi-site setup allows you to have a single CMS site as a base (default site) and the possibilities to let the administrator create additional new sites that share the same root page, database and code base. The additional sites are either automatically mapped and requires no additional configuration (if the base site is mapped to wild card) or needs manual configuration of host name. When working in a multi-site setup you see all sites in the same interface which makes it easy to work with them. One reason to run a multi-site setup with specific host name mapping (which means 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 stay running.
Setting up multiple sites briefly is done in the following steps:
- IIS to configure host name mapping to websites, to listen to any host name or specific host names
- EPiServer CMS admin view to add a new website
Requirements
A multi-site setup has the following requirements:
- Each site must have a unique URL and start page in the content tree. Start pages cannot be nested.
- A multi-site license defining the maximum number of sites the installation is licensed for.
- Adding new sites without making changes to the server requires that IIS is configured without host headers (since that would require an administrator to manually add new host headers when new sites are added).
- All sites must have the same root path which must be identical to what is configured in IIS. This means that you cannot have one site as a virtual directory and another as an IIS site.
Adding a website from admin view
If the IIS application is configured to respond to any host name, then new sites can easily be launched from the CMS administration view, without any additional configuration needed. To define multiple sites, go to the 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.
Only a start page and a URL for the new site is needed. The URL and start page are stored in the database, and new sites will automatically be provisioned. When launching new sites you can also configure them to use site-specific assets if desired. For instance when creating 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 will have the * (wildcard) host mapping. You can also easily add additional hosts mappings such as partner.examplesite.com, customer.examplesite.com, optionally bound to a specific language. Additional hosts that only should redirect to the main host can also be setup. If there is a specific host that should serve as the primary host for a specific language and the target for all redirects, this can also be setup here. 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, for instance templates, does not need to take into account that multiple websites exist, since CMS will automatically route requests to the correct site. You can access the current site using the SiteDefinition.Current property (in namespace EPiServer.Web). Example of 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.
Additional information
Security
A possible misconception regarding authentication in multi-site setup is that logging out on one site while being logged in on other sites would log you out from these websites as well. This is not the case since by default when using Forms Authentication, authentication is stored in a cookie per domain in the visitors browser.
Mapping IIS sites to CMS sites
Even though CMS is multi-tenant, it is still possible to 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 would be 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 running CMS in multiple processes, the event system has to be configured for inter-process events. As a best practice, always consider using load balancing for fault tolerance instead of separating sites into IIS sites.
See also
Do you find this information helpful? Please log in to provide feedback.