A context root allows you to use a single application for multiple sites when using a path-based strategy for site base URLs by creating a path mapping to a Web application. You can map a standard context root to your site that was configured for your application server, or you can create virtual context roots.

Virtual Context Roots

A virtual context root is a context root that does not map to a physical Web application. If the Site Base URL or Alternative URL field uses a virtual context root, the Context Root URL field should be configured to contain the value for the actual context root that maps to a physical Web application.

Virtual context roots allow you to map multiple context roots to a single Web application, allowing you to use a single site to serve multiple sites. For example, if you have a Web application whose context root is /sports but you want to create two separate site configurations that use this Web application, you could set the context root site property to /sports for each site configuration and set the site configurations’ Site Base URLs field to virtual context roots such as /hockey and /basketball.

By default virtual context roots are disabled. To enable them, you must set the enabled property to true in the VirtualContextRootsService.properties file.

Virtual context root mapping is repository-based. You can extend your site category to use a default context root. If the default context root is available, it is included in any sites created with the category. When configuring a new site, use the Site Base URL field to supply the virtual context root string that maps the site to the actual context root.

You can configure virtual context roots with domain names. For example, sports.com/hockey and olympichistory.com/hockey use /hockey as a virtual context root. The VirtualContextRootService searches for a context root match first by checking against the full domain name and the servlet path URL, and then by checking just the servlet path URL to ensure that the user is directed to the correct site and context root.

To associate the context root property with the virtual context root, the site developer must map the two in the Site Repository as well as configure the appropriate web.xml file.

For additional information on configuring virtual context roots, refer to the Multisite URL Management section in the ATG Platform Programming Guide.