More in this section

Forums / Developing with Sitefinity / URL rewriting for first level directory

URL rewriting for first level directory

3 posts, 0 answered
  1. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    19 Mar 2010
    Link to this post
    We are running into problems with the URL rewriting for the first subdirectory of the site.

    Here is our layout (with some obfuscation):
    <rule>
      <url>/product/prices</url>
      <rewrite>/company/products/details/prices</rewrite>
    </rule>
    <rule>
      <url>/product/product-history</url>
      <rewrite>/company/products/details/product_history</rewrite>
    </rule>
    <rule>
      <url>/product/</url>
      <rewrite>/company/products/list</rewrite>
    </rule>


    So, someone can navigate to http://ourdomain.com/product/ and get the main page for the product. The trailing slash is required, as the rule is specifically for /product/

    This is slightly annoying, but we can live with it. However, the bigger problem is that any ASP.Net postback onto this page will remove the trailing slash, which leads to a 404 error.

    If I change the first rule to just /product  (without the trailing slash), it causes problems for other pages. For instance, the second rule won't work any more because both instances of "/product" are replaced to become /company/products/list/company/products/list-history

    Thanks,
    David
    Is there any way to write the rule to only the /product URL?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Mar 2010
    Link to this post
    Hi David,

    The URL rewriting uses regular expressions to match the requested urls and rewrite them appropriately. You can use this tool to build your regular expressions which will match domainame/product for example and not product in deeper levels.

    Kind 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.
  3. David
    David avatar
    34 posts
    Registered:
    26 Feb 2010
    23 Mar 2010
    Link to this post
    Great - thanks.

    The solution I used is another rule like:

    <rule>
      <url>/product$</url>
      <rewrite>/company/products/list</rewrite>
    </rule>
Register for webinar
3 posts, 0 answered