Unable to get ISAPI Rewrite to load

Topics: User Forum
Oct 24, 2006 at 7:27 PM
Hi,

I'm trying to get ISAPI Rewrite to load on my Win2k3 Server box. I add the dll to my ISAPI filters tab in IIS and restart IIS. Looking back on the ISAPI filters tabs shows a red arrow (not loaded) in the status column. I'm using an unmodified .ini file that came in the zip package just to try to get it to load up.

Any advice on how to get this working is greatly appreciated.
Oct 24, 2006 at 7:30 PM
Looking at the Event Viewer gives this error message:
The HTTP Filter DLL C:\Inetpub\websites\Pathfinder\Rewrite\IsapiRewrite4.dll failed to load. The data is the error.
Oct 25, 2006 at 6:27 AM
If you are using Windows 2003, you need to permit the DLL access via the security configuration. Also what permissions have you assigned to it?
Oct 25, 2006 at 9:49 AM
Thanks for your message. I've added the dll to the allowed Web Service Extensions and also given full control to IIS_WPG, IUSR and IWAM accounts for both the dll and ini files. Is there something else I should do?
Oct 26, 2006 at 8:55 AM
That should suffice. Make sure the DLL loads when you restart IIS.
Oct 26, 2006 at 9:46 AM
That's the problem - it won't load up when I restart IIS, no matter what I do! Does anyone have any other ideas?!
Coordinator
Oct 27, 2006 at 12:28 AM
What version are you using?

can you run the testDriver.exe on your server (from a command prompt)? That should verify that the DLL is valid and the necessary pre-reqs are in place.

-Cheeso
Oct 27, 2006 at 3:51 PM
Not sure how but it's now working - very odd! Having difficulties with my rules now (seems much more difficult to configure that IIS Rewrite (but far more powerful!)). I'll fiddle a bit more but I might have to post another plead for help.

Thanks for your help so far.
Coordinator
Oct 27, 2006 at 6:56 PM
ok gotcha.

Yes, IIRF is a challenge to configure. The regular expressions make it particularly challenging. Regex is powerful but obtuse and hard to learn and hard to get right. I feel your pain. But I don't know a better way to do pattern matching of the type we need in a URL rewriter!

-Cheeso


Oct 29, 2006 at 10:04 AM
Well I've got everything working correctly after a lot of fiddling! I don't know if I'm interpreting the output of the testdriver incorrectly but it seems to display the exact opposite of what really happens. Here are my rules:

RewriteCond %{HTTP_URL} ^(?!/images/|/stylesheets/|/graphics/|/admin/).* I
ReWriteRule ^/(.)(\?|/\?)(.*)$ /menu.asp?$3 I,U,L

So what I'm saying here is as long as the requested URL doesn't contain /images/, /stylesheets/, /graphics/ or /admin/, then rewrite any URL as /menu.asp and append any querystring to the end of it.

I test these rules with:
/director
/images/dfsd.jpg
/stylesheets/default.css

So you'd expect /director to be rewritten as /menu.asp? and the other two URLs to remain unchanged. But TestDriver reports:

NO ACTION '/director' ==> --

Sun Oct 29 09:55:19 2006 - Rule 1 : 4 matches
Sun Oct 29 09:55:19 2006 - EvaluateConditionList: TRUE, Rule will apply
Sun Oct 29 09:55:19 2006 - Result (length 18): /menu.asp?dfsd.jpg
Sun Oct 29 09:55:19 2006 - Last if Match

REWRITE '/images/dfsd.jpg' ==> '/menu.asp?dfsd.jpg'

Sun Oct 29 09:55:19 2006 - Rule 1 : 4 matches
Sun Oct 29 09:55:19 2006 - EvaluateConditionList: TRUE, Rule will apply
Sun Oct 29 09:55:19 2006 - Result (length 21): /menu.asp?default.css
Sun Oct 29 09:55:19 2006 - Last if Match

REWRITE '/stylesheets/default.css' ==> '/menu.asp?default.css'

So, am I going mad (as when I use this ruleset on my site it works as expected), or is there a bug somewhere?

Cheers.
Oct 29, 2006 at 3:19 PM
Just noticed that the forum software has mangled my rewrite rules. The period in brackets at the start should in fact be followed by as asterisk.
Oct 29, 2006 at 3:21 PM
And there should be an asterisk after the second question mark. Here it is again:

ReWriteRule ^/(.asterisk)(\?|/\?asterisk)(.asterisk)$ /menu.asp?$3 I,U,L
Coordinator
Oct 31, 2006 at 9:01 PM
Ahhh, the use of testdriver does not work with Server variables.

there is a brief note in the readme about this, it says:

- Not possible to test RewriteCond with server variables via
TestDriver.exe, or, to test U modifier with TestDriver.exe

Perhaps I should make that notice more prevalent.

FYI
Please note: the testdriver does not run within the context of an IIS server, and so does not work with HTTP Server variables. In particular, if you use RewriteCond in the ini files that you test with testdriver.exe, and those RewriteCond statements reference Server variables (eg %{HTTP_URL}) , those RewriteCond statements will not behave in the testDriver the same way they will behave in an ISAPI. In general, it is not possible to use testdriver to evaluate any ruleset that relies on HTTP Server variables.

So that addresses the most recent question you had.
Now, what is the original issue?


-Cheeso

Coordinator
Oct 31, 2006 at 9:02 PM
to answer your question directly,
yes, there is a bug in testdriver in that it does not support Server variables.

This bug is noted in the readme.
at this time, I have not yet imagined how to fix it, so it is not scheduled to be fixed.

-C
Nov 1, 2006 at 11:52 AM
OK, that's cool - I missed the line about TestDriver not working with server variables. It would be good if this was made clearer in the readme!
Coordinator
Nov 1, 2006 at 7:47 PM
Antlane, yes, a good suggestion.
I have added the stanza under "FYI" to the readme.
-cheeso