Regular expression works on one server but not on another

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 25 Nov 2013, 17:50

Regular expression works on one server but not on another

25 Nov 2013, 18:24

We are considering a webhosting change. Both providers have ISAPI_Rewrite 3.0 installed. The .htaccess file on our current server has been working flawlessly for two years. The new provider instructed us to use httpd.ini but assured us that there are no other differences.

On the new server, I can't get any regular expressions working that have more than one directory level. For testing I've hugely simplified our httpd.ini:

Code: Select all
RewriteEngine On

RewriteRule ^solarfonds\.asp$  index.aspx [R=301,NC,L]
RewriteRule ^genussrecht/([0-9]+)?/([A-Za-z0-9-]+)$ index.aspx [NC,L]


The first statement www.ourdomain.de/solarfonds.asp instantly redirects to www.ourdomain.de/index.aspx.
However, the second statement, for example www.ourdomain.de/genussrecht/82/german-pellets-genussrechte-gmbh, always returns error 404.

Any ideas? Thank you!

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

Re: Regular expression works on one server but not on anothe

25 Nov 2013, 20:48

Hello,

a) ISAPI_Rewrite3 doesn't use httpd.ini. It uses httpd.conf.
b) If the issue is that mystical, lets take a look at the logs. Logging issues are described in FAq - http://www.helicontech.com/forum/10648-FAQ.html

Regards
Andrew

User avatar
Posts: 3
Joined: 25 Nov 2013, 17:50

Re: Regular expression works on one server but not on anothe

26 Nov 2013, 14:45

Thank you so much for your quick answer, Andrew!

Below is the information I just got from our new hosting provider:

Their httpd.conf:
# Registration info
RegistrationName= ECS-Webhosting
RegistrationCode= xxxxx
AccessFileName httpd.ini

error.log:
There are only these type of entries:

[26.11.2013 07:23:43] ISAPI Filter loaded. Version 3.1.0.79. Windows 5.2 (Build 3790 ServicePack:2) ProductType SERVER. CPU type INTEL NumberOfProcessors 4.
[26.11.2013 07:29:46] ISAPI Filter loaded. Version 3.1.0.79. Windows 5.2 (Build 3790 ServicePack:2) ProductType SERVER. CPU type INTEL NumberOfProcessors 4.
[26.11.2013 07:55:17] ISAPI Filter loaded. Version 3.1.0.79. Windows 5.2 (Build 3790 ServicePack:2) ProductType SERVER. CPU type INTEL NumberOfProcessors 4.
[26.11.2013 08:05:50] ISAPI Filter loaded. Version 3.1.0.79. Windows 5.2 (Build 3790 ServicePack:2) ProductType SERVER. CPU type INTEL NumberOfProcessors 4.

C:\Programme\ISAPI\ISAPI_Rewrite3\Helicon Manager.exe

Config:
C:\Programme\ISAPI\ISAPI_Rewrite3\httpd.conf

About:
Version 3.1.0.79
Registered to: ECS-Webhosting

Their httpd.ini looks a little different, however, ECS previously used ISAPI Rewrite 2.0:

RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase

#301 Rewrites
RewriteRule ^/(.*)/dotnetnuke-hosting.htm$ /$1/webhosting-produktberater.php?aspnet=true&mssql=true&tag=DNN
...


Does that give you any clues? I guess, the error files won't have any substantial content unless our hosting provider enables RewriteLogLevel 9 and LogLevel debug in their httpd.conf...

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

Re: Regular expression works on one server but not on anothe

26 Nov 2013, 15:05

This explains why they are using htttpd.ini (they simply renamed the config file inside httpd.conf). But aside of that we don't see anything abnormal.
Yes, rewrite.log would really help.

User avatar
Posts: 3
Joined: 25 Nov 2013, 17:50

Re: Regular expression works on one server but not on anothe

09 Dec 2013, 23:05

Sorry that it took me so long to reply. Our hosting provider enabled logging and sent us the log files including rewrite.log but they didn't give us any hints.

I was finally able to resolve our rewrite file. On all the RewriteRules with multiple hierarchy levels I took out the string terminating $. The single level rules did not work without the starting/terminating pair ^…$

Going back to my examples, the second rule did NOT work:
RewriteRule ^solarfonds\.asp$ index.aspx [R=301,NC,L]
RewriteRule ^genussrecht/([0-9]+)/([A-Za-z0-9-]+)$ index.aspx [NC,L]


Now the second rule works:
RewriteRule ^solarfonds\.asp$ index.aspx [R=301,NC,L]
RewriteRule ^genussrecht/([0-9]+)/([A-Za-z0-9-]+) index.aspx [NC,L]


I also added
RewriteBase /

although this didn't seem to make any difference.

Before discovering the $ phenomenon I had added
RewriteCompatibility2 Off

assuming that version 2 compatibility might propagate through from the httpd.conf file but this did not solve my problems.

I still find it very bizarre; in particular because our original file works perfectly fine on the other server.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests