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

Forums / Developing with Sitefinity / URL Rewrite with query string not working

URL Rewrite with query string not working

3 posts, 0 answered
  1. OakTree Digital
    OakTree Digital avatar
    27 posts
    Registered:
    06 Sep 2012
    17 Aug 2010
    Link to this post
    We have the AdvancedUrlRewriter enabled, and are having issues with rules that contain querystrings. The following rule is working correctly:

    <rule>
        <url>test.aspx</url>
        <rewrite>TestPage.aspx</rewrite>
    </rule>

    However, when we create a rule with a querystring (no dynamic replacement necessary) such as the following, it does not work:

    <rule>
        <url>test.aspx?test=1</url>
        <rewrite>TestPageA.aspx</rewrite>
    </rule>

    We simply get an 404 saying that test.aspx could not be found.

    Perhaps we're doing something wrong?

    Thanks
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Aug 2010
    Link to this post
    Hi Stuart Peschka,

    Thank you for using our services.

    The problem is that the '?' character has a special meaning in regular expressions. This is why it is not matching your rules. You should try with something like this:
    <rule>
        <url>test.aspx\?test=1</url>
        <rewrite>TestPageA.aspx</rewrite>
    </rule>

    It would be also good if you match the url in groups so that you can pass the query string to the rewritten url. Something like the bellow rule:
    <rule>
        <url>(test.aspx)\?(test=1)</url>
        <rewrite>TestPageA.aspx?$2</rewrite>
    </rule>


    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. OakTree Digital
    OakTree Digital avatar
    27 posts
    Registered:
    06 Sep 2012
    18 Aug 2010
    Link to this post
    That did it. Thanks!
Register for webinar
3 posts, 0 answered