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:

  1. 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.

  2. Open your Internet Information Services (IIS) Manager console (Start -> Control Panel -> Administrative tools -> Internet Information Services (IIS) Manager).
  3. Create two applications under your web site:

    • [IIS web site]/Kentico1 - set the Physical path to the CMS folder of Web1

    • [IIS web site]/Kentico1/Kentico2 - set the Physical path to the CMS folder of Web2 (the child website)

    You now have two independent applications in IIS, one nested under the other.

  4. Edit the web.config of the nested application (Web2) and remove all module and handler definitions. This avoids 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 Kentico1 site to the Kentico1/Kentico2 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.