0

I am having trouble with a pesky URL rewrite, the URL ~/global/products/en/page?sdfsdf=sgdfg works perfectly without the query string but wont work with it. Can anybody help? The mobile site ~/global/products/en/m/page uses the same rules which is why there is the [a-zA-Z0-9/_-]*? in the middle. Rule 6 is my attempt to fix it but I am awful at regex in general so any help would be most appreciated.

<add name="rule1" 
     virtualUrl="^~/[a-z-]*/([a-zA-Z0-9/_-]*?[^\.])$" 
     rewriteUrlParameter="ExcludeFromClientQueryString"   
     destinationUrl="~/country/$1.aspx" 
     ignoreCase="true" />
<add name="rule2" 
     virtualUrl="^~/[a-z-]*/([a-zA-Z0-9/_-]*?)(.+)\?(.*)$" 
     rewriteUrlParameter="ExcludeFromClientQueryString"    
     destinationUrl="~/country/$1.aspx?$2" 
     ignoreCase="true"/>
Paul Alan Taylor
  • 10,474
  • 1
  • 26
  • 42
Chiefy
  • 179
  • 2
  • 17

1 Answers1

2

Change ExcludeFromClientQueryString to IncludeQueryStringForRewrite

Like so:-

<add name="rule1" 
     virtualUrl="^~/[a-z-]*/([a-zA-Z0-9/_-]*?[^\.])$"           
     rewriteUrlParameter="IncludeQueryStringForRewrite" 
     destinationUrl="~/country/$1.aspx"  
     ignoreCase="true" />
<add name="rule2" 
     virtualUrl="^~/[a-z-]*/([a-zA-Z0-9/_-]*?)(.+)\?(.*)$" 
     rewriteUrlParameter="IncludeQueryStringForRewrite" 
     destinationUrl="~/country/$1.aspx?$2" 
     ignoreCase="true"/>
Paul Alan Taylor
  • 10,474
  • 1
  • 26
  • 42