Configuring nested websites
A nested website is a site that users can access through a URL sub-directory under the domain name of a different website. The following steps demonstrate how to create two Kentico sites that utilize nesting:
Install two Kentico web projects into separate folders.
Choose folder names different than the virtual directory names you plan to use in the URL. This prevents collisions when setting up the IIS. For example:
- Inetpub/wwwroot/NestedWeb/Web1
- Inetpub/wwwroot/NestedWeb/Web2
You now have two completely independent instances of Kentico, each with its own web project and database.
Open your Internet Information Services (IIS) Manager console (Start -> Control Panel -> Administrative tools -> Internet Information Services (IIS) Manager).
Create two applications under your web site:
- [IIS web site]/KenticoCMS1 - set the Physical path to Web1
- [IIS web site]/KenticoCMS1/KenticoCMS2 - set the Physical path to Web2 (the child website)
You now have two independent applications in IIS, one nested under the other.
Edit the web.config of the nested application (Web2) and remove all module and handler definitions. This avoid duplicate module and handler definitions of the two applications.
If you have any additional custom keys in these configuration sections, ensure that they are not duplicated in the two web.config files, i.e. that they are only added in one of the two files.
<system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules> // remove or comment out all keys in this section </modules> <handlers> // remove or comment out all keys in this section </handlers> </system.webServer>
The websites are now accessible via nested URLs. You can configure the websites independently without any issues.
Additional configuration for Staging
This section describes how to set up Content staging on nested websites.
Staging uses sections in the web.config that collide on nested websites. Config files are inherited within the IIS virtual directory structure (even when the projects are not nested on the file system), but you cannot have the same section of web.config twice in the config file.
If you configure staging from the KenticoCMS1 site to the KenticoCMS1/KenticoCMS2 site, the inner project may have issues with the configuration.
If you get the “The username token has already been added” error message, some of the configuration is duplicated. User name token authentication is defined in the policy file, which is referenced from the <microsoft.web.services3> section.
You need to remove the whole <microsoft.web.services3> section from the web.config of the nested web project (Web2). Do not remove the section from the Web1 (outer) project, since both websites will use this configuration.
Staging between the nested sites should now work correctly.