3

I've got a project where we're re-building a site for a client, the new site is using umbraco on the .net platform. the old site was cold fusion.

Umbraco utilises the urlrewriting.net library so I created all the 301 recirect rules for the old cold fusions urls but this one is causing an infinite loop.

    <add name="r66" virtualUrl="^~/thing_info/index.cfm.D413249D-BCD8-304B-02CD-561DAC70641E$"
                destinationUrl="~/about-us/award-winning-product" redirect="Application" redirectMode="Permanent" ignoreCase="true" />

I know "." has a special meaning but it works well enough, also I've used "." to match any character including the "?" character beginning the query string. if I visit try the url without a querystring like so

http://staging.site/thing_info/index.cfm-D413249D-BCD8-304B-02CD-561DAC70641E

then I get redirected correctly to

http://staging.site/about-us/award-winning-product

However if I try the url (question mark is the only difference)

http://staging.site/thing_info/index.cfm?D413249D-BCD8-304B-02CD-561DAC70641E

Then I end up in a redirect loop to itself. (I checked the response header)

Does anyone have any idea if I've done something wrong or if it's a bug in the urlrewriting.net library? or how to correct the problem?

Myster
  • 17,704
  • 13
  • 64
  • 93

3 Answers3

5

By default UrlRewritingNet will not include the querystring in the pattern match. to enable this you need to add the following attribute rewriteUrlParameter="IncludeQueryStringForRewrite"

<add name="r66" virtualUrl="^~/thing_info/index.cfm.D413249D-BCD8-304B-02CD-561DAC70641E$"
     destinationUrl="~/about-us/award-winning-product" redirect="Application" redirectMode="Permanent" 
     ignoreCase="true" rewriteUrlParameter="IncludeQueryStringForRewrite" />

Give this a try and let me know if it works.

Jonathan

Jonathan Stanton
  • 2,531
  • 1
  • 28
  • 35
2

Its a regular expression so the . means any character. You could try escaping the dot with . or the question with \? to match that character specifically.

BeaverProj
  • 2,205
  • 1
  • 17
  • 31
2

I had the same problem when trying to do a permanent 301 redirect using umbraco and UrlRewritingNet.

After reading this and some hair pulling I got it working with the following entry in umbraco/config/urlrewriting.config

<add name="Rule1885"
      virtualUrl="^~/whats-on/event\.aspx\?id=1885"
      destinationUrl="~/whats-on/event.aspx?id=1822"
      rewriteUrlParameter="IncludeQueryStringForRewrite"
      redirectMode="Permanent"
      redirect="Application"   
      ignoreCase="true" />

It was the combination of Jonathan's answer, to add rewriteUrlParameter="IncludeQueryStringForRewrite", and escaping the virtualUrl parameter correctly that sorted it out.

brodie
  • 5,354
  • 4
  • 33
  • 28