Using the IIS7 Rewriter and Database

My company has evolved from an old website to a new one, and we have a bunch of old pages with the following URLs:

  • 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

These URLs should be sent to the following pages:

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

I can make it work using in my web.config, but there are so many, I would prefer to do it in the database. I was 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 problem is that all of my source examples are redirected to www.example.com/ProductA. It is as if they were ignoring query strings. Any idea how to fix this? My rule in my configuration file:

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

The URL provided in the tag does not include the query string, so you will not see it in your R: 1, you can change your condition to be something like:

 <add input="{DB:{R:1}?{QUERY_STRING}}" pattern="(.+)" /> 
+1
source

Source: https://habr.com/ru/post/1315855/


All Articles