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

URL rewriting

7 posts, 0 answered
  1. David
    David avatar
    26 posts
    Registered:
    12 Jul 2008
    06 Jul 2009
    Link to this post
    Is there any way to make all URL's in a site be lower case? I can kind of get around standard pages by just giving them good names but for things like news articles, the URL is generated automatically so I can't force lowercase.

    Thanks for your time
    Dave Cooper
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Jul 2009
    Link to this post
    Hello David,

    Here is what you should do to make the News items Urls in lowercase:

    1. Override the NewsView control Create a new class in the App_Code directory:
    LowerCaseNews.cs:
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.News.WebControls; 
     
    namespace Sitefinity.Samples 
        /// <summary> 
        /// Summary description for LowerCaseNews 
        /// </summary> 
        public class LowerCaseNews : NewsView 
        { 
            public LowerCaseNews() 
            { 
                // 
                // TODO: Add constructor logic here 
                // 
            } 
            public override Type LocalizationAssemblyInfo 
            { 
                get 
                { 
                    return typeof(NewsView); 
                } 
                set 
                { 
                    base.LocalizationAssemblyInfo = value; 
                } 
            } 
            public override Type AssemblyInfo 
            { 
                get 
                { 
                    return typeof(NewsView); 
                } 
                set 
                { 
                    base.AssemblyInfo = value; 
                } 
            } 
            protected override string GetItemUrl(Telerik.Cms.Engine.IContent contentItem, string singleItemUrl) 
            { 
                return base.GetItemUrl(contentItem, singleItemUrl).ToLower(); 
            } 
        } 

    Note the GetItemUrl overriden method. It returns the same Url but in lower case.

    2. Register the new control in the web.config file:
    web.config:
    <toolboxControls> 
            <clear /> 
            <add name="CustomNewsView" section="New" type="Sitefinity.Samples.LowerCaseNews, App_Code"/> 

    The control should be now visible in a section named "New" in the Control toolbox.

    3. Use the overridden control instead of the NewsView control

    There is a way to make all Urls in lowercase, with a HttpModule, but this is a bit dangerous, since there are requests to internal files, and those requests are case sensitive. Such requests are all done to the ScriptResource.axd for example.


    Don't hesitate to contact us if you have other questions.

    Best wishes,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Jul 2009
    Link to this post
    Hello David,

    Here is a quick follow up on my last post. Actually, there is an easier way to enable lowercase URLs for Generic Content based modules:
    web.config:
    <cmsEngine defaultProvider="Generic_Content"
    <providers> 
     ... 
     <add name="News" lowercaseUrls="true" .../> 

    Add the highlighted property and set it to true. The change is done in the web.config file.

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. JAllen
    JAllen avatar
    34 posts
    Registered:
    23 Dec 2010
    15 Mar 2011
    Link to this post
    I came across this thread and want to implement lower-case URLs in 3.7sp4.  The code suggested doesn't seem to do the trick - am I missing something or has this been removed from 3.7sp4?

    Thanks,
  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Mar 2011
    Link to this post
    Hello JAllen,

    I've just checked this, but it's not missing from the SP4. 
    Can you please send us the web.config file?

    Regards,
    Georgi
    the Telerik team
  6. JAllen
    JAllen avatar
    34 posts
    Registered:
    23 Dec 2010
    18 Mar 2011
    Link to this post
    Hi Ivan,
    I've just gone back to check and it looks it is working now... must've needed to restart the application to take effect.

    Thanks!
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Mar 2011
    Link to this post
    Hello JAllen,

    Thanks for the update. 
    Good luck with the project.

    Greetings,
    Georgi
    the Telerik team
Register for webinar
7 posts, 0 answered