KB's

Domain-Page mapping

In Sitefinity 3.7, you can map domains to specific pages without the need to write any code.

What does “Domain – Page mapping” mean?

You can map a specific CMS page in the site to a specific domain. So when the site is accessed via this domain, the mapped CMS page behaves as a root of the site.

The implementation was initially started in the following forum post: http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/sub-domains.aspx

Configuration:
All you need to do is to specify the mapping configuration rules under telerik/cms section in the web.config:
<urlMappings>
<add key="<domain>" value="<page_path>" />
<add ... />
...
</urlMappings>


where
<domain>  is the name of the domain, i.e. www.mysite.com, blogs.mysite.com, etc.
<page_path> is the path to the page relative to the SiteMap root (without extension), i.e. blogs, home/internal

The key and value attributes are required.
In the mapping <add> element, you can also specify shared attribute, which expects True ot False. It is optional with default value False. If shared="true", the mapped page node will be visible and accessible to the other domain; otherwise, it will be hidden for it.

Sample scenario:

For example, you have to create 3 Web sites:

-mysite.com – the main Web Site

-blogs.mysite.com – for Blogs

-forums.mysite.com – for Forums

The three sites will share same resources, and you want to use single sign-in to manage their contents.

The Site Map will have the following pages:

-Home

-About

-Blogs

- Posts

-Forums

- Posts

Without mapping, the blogs' posts will be accessible with:

mysite.com/blogs/posts.aspx

and the forums' posts with:

mysite.com/forums/posts.aspx

After applying the following domain mapping in the web.config:

<cms defaultProvider="Sitefinity" ...>
<urlMappings>
<add key="blogs.mysite.com" value="blogs" shared="true" />
<add key="forums.mysite.com" value="forums" shared="false" />
</urlMappings>


.. when the Web Site is accessed via blogs.mysite.com, it will be opened starting from the blogs page. However, the blogs page will be still accessible through the other domains, because its shared attribute is set to True.

The forums page will be accessible only through forums.mysite.com.

Testing:

You can test it in your localhost before going to production. In order to do this you should edit <path_to_windows>\System32\drivers\etc\hosts file by adding the domains you want to test:

127.0.0.1       localhost 
::1             localhost 
 
127.0.0.1       blogs.mysite.com 
127.0.0.1       forums.mysite.com 

Don't forget to rollback your changes after finishing with the tests.

The "Domain - Page mapping" is the default implementation of the CmsUrlMappingService. However, it is easy to build a custom mapping, based on the current HttpContext like "User - Page mapping" or "Cookie - Page mapping", which defines different SiteMap roots for specific users or for specific value in the cookie. How to do this will be handled in another KB.