URL Rewriting in asp.net mvc umbraco

129 views Asked by At

I need to know when following rule didn't match, It should go to the error page.

For example "sample-code" or "-my-code.html" keyword mismatch It will redirect to error page.

<add name="Results" 
   virtualUrl="^~/(UK|USA)/sample-code/([^/]+)-my-code.html" 
   rewriteUrlParameter="ExcludeFromClientQueryString"    
   destinationUrl="~/my-pages/example.aspx?region=$1&amp;location=$2" 
   redirectMode="Permanent" ignoreCase="true" />

Please let me know find a solution for above problem.

1

There are 1 answers

0
Tim On

It looks like you're using the built in rewrite module that ships with Umbraco. Unfortunately that doesn't support the functionality you're looking for.

You need to use the IIS Rewrite module instead, as that supports negating rules. You could then create a rule that will catch all URLs, but that is negated by correctly matching the pattern.