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?
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?
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?
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" />
is working on a reply...