How to configure site-specific aliases

  • Description

    Sitecore implements Aliases functionality to allow configure multiple web site URLs to access any content item.

    You can read more about aliases in the Data Definition Cookbook:
    https://sdn.sitecore.net/upload/sitecore6/datadefinitioncookbook-a4.pdf

    By default, aliases configuration is shared between all Sitecore sites from a Sitecore solution.

    In some scenarios, it may however be required to configure site-specific aliases.

    For example:

    • Some aliases may need to be configured to work only with certain sites.
    • Different sites may need to have aliases with the same name pointing to different site-specific items.

    This article describes how to customize aliases functionality to introduce site-specific aliases.

  • To implement site-specific aliases, perform the steps below:

    1. Replace the default AliasResolver processor of the httpRequestBegin pipeline with the custom one that takes into the account the context site name when resolving aliases. Use the AliasResover.cs file as an example.
    2. Under the /sitecore/system/Aliases item, create folders with the name of the sites that require support for site-specific aliases. Check the site names in the <sites> section of the web.config file.
      For example, items hierarchy may look like the following:
      sitecore
      --system
      ----aliases
      ------website
      ------website2
      ------website3
      
      This would allow aliases placed under the site folders to only apply to the corresponding Sitecore sites.
    3. Create aliases by manually creating alias items under the corresponding site folder. Alternatively, use Aliases dialog from the Presentation ribbon, while always add the <websiteName>/ prefix before the actual alias name when using this dialog.
    4. If there is a need to create global aliases that would work for all sites, place corresponding alias items under each site folder.
    Notes:
    • After the above customization, only aliases placed under the site folders will be resolved.
    • To allow selecting all child items of the /sitecore/content node using the Linked Item field, perform the following steps:
      1. Navigate to the /sitecore/templates/System/Alias template.
      2. Change the Source value of the Linked Item field to /sitecore/content.

Applies to:

CMS 6+

September 11, 2015
September 11, 2015

Reference number:

303189

Keywords: 

  • CMS