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

Forums / Developing with Sitefinity / urlrewrites to root level

urlrewrites to root level

3 posts, 0 answered
  1. Tys
    Tys  avatar
    8 posts
    Registered:
    04 Mar 2009
    11 Nov 2009
    Link to this post
    Hi everyone,

    I've search through the forum and found some similar questions, but didn't find a good answer.

    I'm implementing the URL rewrites that comes with SiteFinity and my goal is to rewrite the following addresses.

    mydomain.com/webshop/cars/45/  > mydomain.com/webshopcategories.aspx?cat=45
    mydomain.com/webshop/cars/brands/bmw/67/ > mydomain.com/webshopcategories.aspx?cat=67
    mydomain.com/webshop/cars/brands/bmw/types/m5/edition/amg/89/ > mydomain.com/webshopcategories.aspx?cat=89

    So there is a unknown number of folders which all end with a categoryId and i want to rewrite that all to the same rootlevel file /webshopcategories.aspx

    I've tried all kinds of things, but since you cant use  <rewrite>~/webshopcategories.aspx?cat=$1</rewrite>
    i'm stuck. It looks like the rewriter just appends my rewrite-to-url at the end of every querystring.
    I'm sure there must be a simple way of doing this, but i can't find it.

    Hoping for some answers,
    Regards, Tys


  2. Tys
    Tys  avatar
    8 posts
    Registered:
    04 Mar 2009
    12 Nov 2009
    Link to this post
    I think the problem with the rewriter is that it does a replace on the position where it finds a match.
    so: mydomain.com/webshop/cars/brands/bmw/types/m5/edition/amg/89/  
    becomes: mydomain.com/webshop/cars/brands/bmw/types/m5/edition/amg/ProductCategories.aspx?id=89

    So i've solved the problem by moving the id's to the beginning of the addresses, like 
    mydomain.com/webshop/89/cars/brands/bmw/types/m5/edition/amg/
    and that becomes: mydomain.com/webshop/ProductCategories.aspx?id=89&ref=cars/brands/bmw/types/m5/edition/amg/
    now the replacement page is the right folder level and is called correctly. 

  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Nov 2009
    Link to this post
    Hello Tys ,

    You can try the following urlRewrite rules

    /webshop/cars/(.*)/(\d{2})
    /webshopcategories.aspx?cat=$1

    You can gather more information about UrlRewriting at MSDN.

    Sincerely yours,
    Ivan Dimitrov
    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.
Register for webinar
3 posts, 0 answered