views:

24

answers:

1

My company converted from an old website to a new one and we have a bunch of old pages with URLs like this:

  • www.example.com?foo.aspx
  • www.example.com?foo.aspx?ID=B&utm_source=Foo
  • www.example.com?foo.aspx?ID=C&utm_source=Foo

Those URLs need to go to these pages respectively:

  • www.example.com/ProductA
  • www.example.com/ProductB?utm_source=Foo
  • www.example.com/ProductC?utm_source=Foo

I can get this to work by using in my web.config but there are so many I would prefer to do it in the database. I have been able to partially successfully switch to the database using the article http://learn.iis.net/page.aspx/803/using-custom-rewrite-providers-with-url-rewrite-module/.

My issue is that all of my initially examples redirect to www.example.com/ProductA. It is as if they are ignoring the Query Strings. Any idea how to fix this? My rule in my config file is:

<rule name="DbProviderTest" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{DB:{R:1}}" pattern="(.+)" />
    </conditions>
    <action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>  
+1  A: 

the URL that is matched in the tag does not include the Query String and that is why you will not see it in your R:1, you should be able to change your condition to be something like:

<add input="{DB:{R:1}?{QUERY_STRING}}" pattern="(.+)" /> 
CarlosAg
That worked, thanks!
RandomBen