Running multiple sites on a single domain
This page describes how to run multiple websites in separate sub-folders on a single domain. In this scenario, you do not need to obtain new domains for each site.
Example - Installing two sites onto a single domain
Install a Kentico web project to the following folder: C:\inetpub\wwwroot\kenticofolder.
- In the installer, choose Custom installation and Built-in web server in Visual Studio (does not create a virtual directory).
Open your Internet Information Services (IIS) Manager console (Start -> Control Panel -> Administrative tools -> Internet Information Services (IIS) Manager).
Create a new virtual directory named kenticoweb.
- The name of the virtual directory must be different than the folder where you installed the web project.
- Set the Physical path to a non-website folder in the root of a local disk. Ideally, create an empty folder for this purpose, for example: c:\empty
Create two IIS applications under kenticoweb named web1 and web2.
- Set the Physical path of both applications to the web site folder of the installed project (C:\inetpub\wwwroot\kenticofolder\CMS in this example).
- Set the application pool according to the type that you specified in the installation of the Kentico web project.
Open your browser and type in either http://localhost/kenticoweb/web1 or http://localhost/kenticoweb/web2.
Log in to the Kentico administration interface and open the Sites application.
Install both sites. Set the Site domain name fields:
- Website 1: localhost/kenticoweb/web1
- Website 2: localhost/kenticoweb/web2
Now when you go to http://localhost/kenticoweb/web1, you will see website 1. If you go to http://localhost/kenticoweb/web2, you will see website 2.
Synchronizing global data for the sites
To ensure the synchronization of settings and global objects between the two sites, you need to set up a Web farm environment.
Add the following keys to the <appSettings> section of the web.config file in the installation directory shared by both websites:
<add key="CMSWebFarmEnabled" value="true"/> <add key="CMSWebFarmSynchronizeFiles" value="false" /> <add key="CMSAllowLocalConfigKeys" value="true" /> <add key="/kenticoweb/web1:CMSWebFarmServerName" value="server1" /> <add key="/kenticoweb/web2:CMSWebFarmServerName" value="server2" />
These keys enable web farms in general and disable synchronization of files, which is not needed since the applications already use the same physical folder. Notice that each application has a different web farm server name specified via a prefix in the name of the CMSWebFarmServerName key. This prefix must match the path that you set for the corresponding application in IIS, including the virtual directory.
Log in to the Kentico administration interface on one of the sites.
Open the Web farms application.
Create a web farm server for each application.
To prevent potential problems with conflicts during Smart search indexing, specify a different physical folder for each application’s search index files through the following web.config keys:
<add key="/kenticoweb/web1:CMSSearchIndexPath" value="App_Data\CMSModules\SmartSearch\Web1\" /> <add key="/kenticoweb/web2:CMSSearchIndexPath" value="App_Data\CMSModules\SmartSearch\Web2\" />
Your websites should now work without any issues.