Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ric Carey 50 posts 93 karma points
    Jul 16, 2013 @ 11:35
    Ric Carey
    0

    Wildcard URL Rewriting

    Hi all,

    Ive set up URLRewriting using the config file, which works great when you know the destination URL, however what if the CMS user changes the page name and thusly updates the URL or the page hasnt been created yet?

    Is it possible to do a wildcard URL Rewrite rule?

    bascially ive got:

     <add name="tourcountry"  virtualUrl="^~/*/*/(.*)/"    rewriteUrlParameter="ExcludeFromClientQueryString"    destinationUrl="~/parent/child/?country=$1"  ignoreCase="true"  />

    which works fine however if i try and put a wildcard in the destinationURL i get dangerous request exceptions or the page cannot be found. So the rewriting will work as long as you hardcode the destination URL.

    Is there any way to do a wildcard for the parent and child folders?

    I tried:

        <add name="tourcountry"  virtualUrl="^~/(.*)/(.*)/(.*)/"    rewriteUrlParameter="ExcludeFromClientQueryString"    destinationUrl="~/$1/$2/?country=$3"  ignoreCase="true"  />

    but that didnt work. Anyone had any luck or is this not possible?

     

  • Ric Carey 50 posts 93 karma points
    Jul 16, 2013 @ 12:12
    Ric Carey
    0

    sorry, my first example was incorrect as it tries to rewrite any page to that virtual url.

    So ive only got it working for hardcoded:

     <add name="tourcountry"  virtualUrl="^~/football-tours/womens-football/(.*)/"    rewriteUrlParameter="ExcludeFromClientQueryString"    destinationUrl="~/football-tours/womens-football/?country=$1"  ignoreCase="true" />
       

Please Sign in or register to post replies

Write your reply to:

Draft