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

Forums / General Discussions / Base folder URLRewrites?

Base folder URLRewrites?

7 posts, 0 answered
  1. Rutger Buijzen
    Rutger Buijzen avatar
    4 posts
    Registered:
    29 Nov 2006
    23 Sep 2010
    Link to this post
    Hi,

    I was wondering if SiteFinity allows user to create base folder redirects, for example:

    http://www.domain.com/abc123 > http://www.domain.com/menu/submenu/abc123.aspx

    I'm struggling with this because I cannot catch this using IHttpModule as long as IIS is not setup in wildcard mode.

    Thanks!
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Sep 2010
    Link to this post
    Hi Rutger Buijzen,

    Thank you for using our services.

    You can use the Sitefinity Advanced Url Rewriter to rewrite requests using regular expressions. This allows you to use built in Sitefinity functionality for rewriting. You can also use custom HttpModule and capure requests to specific URLs and rewrite them to the actual ones. This should be done in begin request method override if you are using custom http module.

    To enable the advanced url rewriter you should
    1) Add a new configuration section in your web.config:
    Copy Code
    <sectionGroup name="telerik">
        ...
        <section name="urlrewrites" type="Telerik.Cms.Web.AdvancedUrlRewriter, Telerik.Cms" />
    </sectionGroup>

    2) Use the rewrite module instead of the default one:
    Copy Code
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="Cms" type="Telerik.Cms.Web.CmsHttpModuleUrlRewrite, Telerik.Cms" />
        <!-- 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" />
    </httpModules>

    for IIS 7.0 it is:
    Copy Code
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
            <remove name="ScriptModule" />
            <remove name="Cms" />
            <!--<remove name="LibraryModule"/>-->
            <remove name="RadUploadModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="Cms" type="Telerik.Cms.Web.CmsHttpModuleUrlRewrite, Telerik.Cms" />
            <!-- 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" />
        </modules>

    3) Provide your url rewrite rules:
    <telerik>
        <urlrewrites>
            <rule mode="PermanentRedirect">
                <url>(?=.*?\b([\w-]+)\b)((?!\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg|css|js|rss|ashx|aspx)).)*$</url>
                <rewrite>/menu/submenu/$1.aspx?</rewrite>
            </rule>
        </urlrewrites>

    The above rule should be sufficient to create permanent redirects like one in question. You can use this tool to text your regular expressions. The rewrite module can also only rewrites - keeping the url in url browser as user has requested it, or temporary redirects.

    All the best,
    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
  3. Rutger Buijzen
    Rutger Buijzen avatar
    4 posts
    Registered:
    29 Nov 2006
    23 Sep 2010
    Link to this post
    Thanks for the quick answer. Still I'm wondering how you can catch the event because

    http://www.domain.com/abc123 is not handled by .Net (it doesn't contain .aspx extension)?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Sep 2010
    Link to this post
    Hi Rutger Buijzen,

    You are correct. IIS should throw a 404 error before the request reaching the http module responsible for handling the rewrite. Unless you install .NET framework 4.0 - it allows you to use extensioless urls without setting a wilcard script map.

    Sincerely yours,
    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
  5. Rutger Buijzen
    Rutger Buijzen avatar
    4 posts
    Registered:
    29 Nov 2006
    24 Sep 2010
    Link to this post
    Thanks Radoslav, do you happen to have a small code example on how to do this in .Net 4.0? Thanks again!!!
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Sep 2010
    Link to this post
    Hi Rutger Buijzen,

    Installing .NET 4.0 framework should automatically create a handler mapping for extensionless urls in your IIS, see the attached image. Note that this site is running in Integrated Pipeline .NET 2.x, not 4.0

    Greetings,
    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
  7. Rutger Buijzen
    Rutger Buijzen avatar
    4 posts
    Registered:
    29 Nov 2006
    24 Sep 2010
    Link to this post
    GREAT!!!
Register for webinar
7 posts, 0 answered