Redirect Fails with DotNetNuke 6 and IIS 7.5

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 08 Aug 2012, 15:06

Redirect Fails with DotNetNuke 6 and IIS 7.5

08 Aug 2012, 16:08

I am preparing to launch a new website for a large hospital health care system. URLs from the old site need to be redirected to the new site. I am attempting to use ISAPI_Rewrite 3.0 to do this, but it is not working as expected.

Both the old and new sites are in DotNetNuke 6.1.5 on Windows Server 2003 and are hosted on the same Windows Server 2008 with IIS 7.5 with IIS 6.0. The old site has been upgrade from DNN 4.x to 5.x and then to 6.x. The new site is a fresh install of 6.x with minor updates to the newest versions.

I have used ISAPI_Rewrite 3 in the past on a DotNetNuke site hosted on Windows Server 2003 with IIS 6.0 and it works fine. I am wondering if the problem is specific to IIS 7.5.

I will make up names for the two sites, but the address to the right of the host/domain is what I am actually using in the httpd.conf.

The old site is: www.myhospital.com
The new site is: dev.myhospital.com

I also added an IIS host header and a DNS A record for old.myhospital.com on the www site for testing. I need to keep the old site online while I develop the RewriteRule entries in the httpd.conf. At launch, I will use 301 redirects, but I am using 302's for testing.

www.myhospital.com and old.myhospital.com point to the old live site.

dev.myhospital.com points to the new site.

For debugging the problem I am having, I also created a new host on another domain on a new website hosted on the same web server as the above two sites. It contains one file, default.aspx with the content "It works!"

Here is the httpd.conf file:

---

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.89

# Registration info
RegistrationName= xxxxxxxxxx
RegistrationCode= xxxxx-xxxxx-xxxxx-xxxxx

RewriteEngine off
AllowOverride none

<VirtualHost old.myhospital.com>
RewriteEngine on
AllowOverride all

RewriteRule ^/Test1/Default.aspx http://www.google.com [R=302,NC,L]
RewriteRule ^/HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx http://dev.myhospital.com/HealthCarebrS ... erapy.aspx [R=302,NC,L]
</VirtualHost>

<VirtualHost test.anothersite.com>
RewriteEngine on
AllowOverride all

RewriteRule ^/Test2/Default.aspx http://www.google.com [R=302,NC,L]
RewriteRule ^/HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx http://dev.myhospital.com/HealthCarebrS ... erapy.aspx [R=302,NC,L]
</VirtualHost>

---

If I browse to:

http://old.myhospital.com/HealthCareSer ... fault.aspx

it should redirect to:

http://dev.myhospital.com/HealthCarebrS ... erapy.aspx

However, it actually redirects to:

http://www.myhospital.com/Default.aspx?TabId=463

I don't understand how the rule to redirect to the dev site results in a redirect to the www site. Digging deeper, I find if I completely remove the VirtualHost sections with RewriteRule lines from the httpd.conf, I get the same result. It appears the rule is being ignored completely and somehow the URL is being mangled somewhere else.

If I browse to:

http://old.thompsonhealth.com/Test1/Default.aspx

Instead of being redirected to:

http://www.google.com

it redirects to:

http://dev.thompsonhealth.com/Test1/Def ... google.com


Notice there is a wrong dev URL, followed by a comma, and then the URL for Google.

If I remove the VirtualHosts and RewriteRule lines from httpd.conf, it redirects to:

http://dev.thompsonhealth.com/Test1/Default.aspx

This also is wrong, but different.


From here, I moved on to testing on www.anothersite.com (not the actual URL). It works!

If I browse to:

http://www.anothersite.com/HealthCareSe ... fault.aspx

it redirects to:

http://dev.myhospital.com/HealthCarebrS ... erapy.aspx

This is the correct redirection.


Also, if I browse to:

http://www.anothersite.com/Test2/Default.aspx

It redirects to:

http://www.google.com

This also is correct.


Why does this work fine for the non-DotNetNuke site, but fail for the DotNetNuke site? How do I fix this?

Any help would be greatly appreciated!

Thanks,
-Pat

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect Fails with DotNetNuke 6 and IIS 7.5

09 Aug 2012, 09:33

Hello Pat,

thank for detailed description, although it was easy to get lost.

Since the host file wasn't chenged and IIS is set up correctly, please, try capturing rewrite.log for the testing request.
As it's a production server it won't be difficult to catch one separate request. More info on logging is in FAQ

Regards
Andrew

User avatar
Posts: 3
Joined: 08 Aug 2012, 15:06

Re: Redirect Fails with DotNetNuke 6 and IIS 7.5

09 Aug 2012, 11:26

Andrew,
Turning on debugging has helped, but I am not sure how to interpret the results. It appears for the hospital site that the actual request I make from my browser doesn't reach URL_Rewriter 3. Instead, the initial request is appearing as uri "/favicon.ico". There is a favicon, so I can understand it being requested, but the initial uri with the pattern I am trying to match is missing.


I browse here:

http://old.myhospital.com/HealthCareSer ... fault.aspx

and see this in Rewrite.log:

192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:59:26 GMT [old.myhospital.com/sid#7][rid#136742648/initial] (2) init rewrite engine with requested uri /favicon.ico
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:59:26 GMT [old.myhospital.com/sid#7][rid#136742648/initial] (1) Htaccess process request
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:59:26 GMT [old.myhospital.com/sid#7][rid#136742648/initial] (3) applying pattern '^/HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx' to uri '/favicon.ico'


However, if I browse to my test site here:

http://www.anothersite.com/HealthCareSe ... fault.aspx

I see this in Rewrite.log:

192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (2) init rewrite engine with requested uri /HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (1) Htaccess process request
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (3) applying pattern '^/HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx' to uri '/HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx'
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (1) escaping http://dev.myhospital.com/HealthCarebrS ... erapy.aspx
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (2) explicitly forcing redirect with http://dev.myhospital.com/HealthCarebrS ... erapy.aspx
192.168.xxx.xxx 192.168.xxx.xxx Thu, 09-Aug-2012 09:57:53 GMT [www.anothersite.com.com/sid#9][rid#41295048/initial] (2) internal redirect with /HealthCareServices/DiabetesandNutritionTherapyCenter/NutritionTherapy/tabid/463/Default.aspx [INTERNAL REDIRECT]


In the first case, the actual uri I am requesting does not appear in the log. Instead, I see /favicon.ico. This does not match the pattern in the config file and no redirection takes place.

In the second case, the actual uri I am requesting appears in the log. It matches the pattern in the config file and the redirection works.

It's appears the request is being intercepted before it reaches Helicon URL_Rewrite 3. Is this possible? Could this be an issue with IIS 7.5, or DotNetNuke 6.2.x?

This is my last day at work before a two week vacation. If there is any way you can assist today it would be greatly appreciated.

Thanks.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect Fails with DotNetNuke 6 and IIS 7.5

09 Aug 2012, 11:40

Here's my best bid on this before I go home:

We had smth like this with SiteCore CMS... Only in IIS7 the developers of Sitecore started taking over the requests BEFORE isapi_rewrite...
In this case we have this directive NotificationType=PREPROC_HEADERS. You put it solemly in httpd.conf and ISAPI_Rewrite becomes first one in the line to take the request. Lets see if it helps you.

Regards
Andrew

User avatar
Posts: 3
Joined: 08 Aug 2012, 15:06

Re: Redirect Fails with DotNetNuke 6 and IIS 7.5

09 Aug 2012, 12:09

Thank you for your quick reply. I tried this and it still is not working. I was able to do what I need using the Rewrite functionality of IIS 7.5, so I am all set for now.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Redirect Fails with DotNetNuke 6 and IIS 7.5

10 Aug 2012, 06:05

I hope you'll get back to us after vacation to find out the reasons and fixes for other customers that use dotnetnuke.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 8 guests