How to check if the "Map Channel names to host header names" feature of MCMS is enabled from within a template

Today I wrote a generic routine which should work on all kind of sites. Unfortunatelly this specific code needed to behave differently for site where the “Map Channel names to host header names” feature of MCMS is enabled or not. So I had to find a way to identify this.

MCMS does not expose this flag in a documented API. After some research I identified that the Url of the root channel will look different if the feature is enabled or not.

When the feature is disabled the Url looks like this: http://servername/Channels
When the feature is enabled the Url looks like this: http://Channels

So implementation of such a check is quite simple:

  private bool MapChannelToHostHeaderEnabled()
      return ((CmsHttpContext.Current.RootChannel.UrlModePublished == “http://Channels/“) ||
                (CmsHttpContext.Current.RootChannel.UrlModePublished == “https://Channels/“));

or if you prefer a more flexibel version which can also be used with CmsApplicationContext or from within a workflow event:

  private bool MapChannelToHostHeaderEnabled(CmsContext ctx)
      return ((ctx.RootChannel.UrlModePublished == “
http://Channels/“) ||
                (ctx.RootChannel.UrlModePublished == “https://Channels/“));


  1. Will the Url still be http:// if the root channel has the RequiresSSL property enabled from your SSL module? Or maybe you need another check…


  2. Hi Jannik,

    you are right. The original version did not cover SSL.

    Have a look at the code above. It will now work also with this module.




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.