More in this section

Forums / Developing with Sitefinity / URL Rewriting with localization - troubleshooting rules...

URL Rewriting with localization - troubleshooting rules...

2 posts, 0 answered
  1. clayman
    clayman avatar
    38 posts
    Registered:
    23 Sep 2009
    23 Nov 2009
    Link to this post

    I need to set up my site to employ url re-writing.  I'm wondering if localization (using PathPrefix persistence mode) needs to be accounted for in the url rules?

    Just to confirm I set it up properly:

    Added the following urlrewrites <section> to <configSections>.
    <configSections> 
     <sectionGroup name="telerik"
       ... 
       <section name="urlrewrites" type="Telerik.Cms.Web.AdvancedUrlRewriter, Telerik.Cms"/> 
       ... 
     </sectionGroup> 
    </configSections> 

    Replaced the default CmsHttpModule httpModule with CmsHttpModuleUrlRewrite.
    <httpModules> 
      ... 
      <add name="Cms" type="Telerik.Cms.Web.CmsHttpModuleUrlRewrite, Telerik.Cms"/> 
      ... 
    </httpModules> 

    Now for the rules, I have some pages that use a querystring and some that don't.

    Here is an example of the querystring rules:
    <rule> 
            <url>/etf/fund/$1</url> 
            <rewrite>/investment-options/exchange-traded-funds/fund-details/fund-summary\.aspx?ticker=(\s+)</rewrite> 
    </rule> 

    Here is an example of the direct mappings:
    <rule> 
      <url>/etf/partners/</url> 
      <rewrite>/investment-options/exchange-traded-funds/partners.aspx</rewrite> 
    </rule> 

    Neither of these rules is working -- I just get 404s -- and I've tried several variations. 

    Could it be that localization is interfering with the rewriting? 

    Thanks
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    24 Nov 2009
    Link to this post
    Hi Clayman,

    Thank you for posting your question in our forums.
    The setup of the URL Rewriter is okay, but the problem comes from the fact that the pattern and the rewrite rule are switched. You should do it exactly the opposite way, let me give you an example:
    <rule>
      <url>home/(.*)/default.aspx</url>
      <rewrite>home.aspx?id=$1</rewrite>
    </rule>

    You should have the match-rule in the <url> element, and the replace pattern in the <rewrite> element.

    As for the localization question, the PathPrefix will be part of the URL so you can write your rules by having it in mind as well.

    I hope this answers the question.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered