+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Alias for languages

Alias for languages

2 posts, 1 answered
  1. Petr
    Petr avatar
    34 posts
    Registered:
    03 Jan 2011
    18 Jan 2011
    Link to this post
    Hi all,

    I need to replace eg. /EN/ string in urls by another (eg. /EU/). Do you have any idea how to do this for SiteMenu control?  I've tried to use url rewrite, but navigation control still contains former language code.

    Thanks for tips

    Petr
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    20 Jan 2011
    Link to this post
    Hi Petr,

    Thank you for using our services.

    Unfortunately this cannot be achieved with the built in URL Rewrite module of Sitefinity. For this you will have to use the IIS UrlRewrite module rewrite both inbound and outbound links. However to be able to use the IIS UrlRewrite module you have to create a class which will override the default Sitefinity CmsHttpModule. You need to override one method and set your site to use this particular class instead of the default one:
    usingSystem.Web;
    usingTelerik.Cms.Web;
      
    /// <summary>
    /// Summary description for CustomCmsHttpModule
    /// </summary>
    public class CustomCmsHttpModule: CmsHttpModule
    {
        protected virtual CmsRequest GetCmsRequest(HttpContext context)
        {
            return new CmsRequest(context.Server.UrlDecode(context.Request.Url.PathAndQuery));
        }
    }

    then edit the web.config:
    <httpModules>
        <add name="Cms" type="CustomCmsHttpModule" />
        <!-- Http Module for extension mappings in Library module.-->
        <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries" />
        <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></httpModules>

    <modules runAllManagedModulesForAllRequests="true">
        <remove name="ScriptModule" />
        <remove name="Cms" />
        <remove name="LibraryModule" />
        <remove name="RadUploadModule" />
        <add name="Cms" type="CustomCmsHttpModule" />
        <!-- Http Module for extension mappings in Library module.-->
        <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries" />
        <add name="RadUploadModule" preCondition="managedHandler" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
        <add name="NetopiaSitefinityFormsModule" type="Netopia.Sitefinity.Forms.FormsModule, Netopia.Sitefinity.Forms" />
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>

    Please note that you will have to set your rewrite rules to exclude .css, js, .jpg and other extensions of files from matching them. Otherwise you risk breaking page styles and functionality.

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
2 posts, 1 answered