Possible Issue?

Topics: User Forum
Oct 6, 2006 at 12:02 AM
I am using IIRF v1.2.10's new -d and -f flags, and I am running into a problem. It works as expected on every 'other' request, but not on every request. What I think is happening is the -d and -f flags are keeping the values off of the last request and checking to see if they are valid, log example below:

Thu Oct 05 16:51:09 2006 - New Url: '/_includes/javascript/lightbox.js'
Thu Oct 05 16:51:09 2006 - ApplyRules (depth=0)
Thu Oct 05 16:51:09 2006 - Rule 1 : -1 (No match)
Thu Oct 05 16:51:09 2006 - ApplyRules: returning 0
Thu Oct 05 16:51:09 2006 - No Rewrite

Thu Oct 05 16:51:18 2006 - New Url: '/products/k_tb/specs/'
Thu Oct 05 16:51:18 2006 - ApplyRules (depth=0)
Thu Oct 05 16:51:18 2006 - Rule 1 : 5 matches
Thu Oct 05 16:51:18 2006 - EvaluateCondition: checking 'E:\Projects\solarbotics.com\alpha\solarbot\_includes\javascript\lightbox.js' against pattern '!-d'
Thu Oct 05 16:51:18 2006 - EvaluateCondition: cond->SpecialConditionType= 'd'
Thu Oct 05 16:51:18 2006 - EvaluateCondition: checking 'E:\Projects\solarbotics.com\alpha\solarbot\_includes\javascript\lightbox.js' against pattern '!-f'
Thu Oct 05 16:51:18 2006 - EvaluateCondition: cond->SpecialConditionType= 'f'
Thu Oct 05 16:51:18 2006 - EvaluateConditionList: FALSE, Rule does not apply
Thu Oct 05 16:51:18 2006 - ApplyRules: returning 0
Thu Oct 05 16:51:18 2006 - No Rewrite

File: "/_includes/javascript/lightbox.js" exists.
File: "/products/k_tb/specs" doesn't exist.

It appears that it's checking whether "/includes/javascript/lightbox.js" exists when it should be checking if "/products/ktb/specs" exists, and causes a failure.

Is there something I'm missing, or is this an issue with that latest release? Any help would be greatly appreciated, please let me know if you have any questions.

Oct 17, 2006 at 9:48 PM
Let me have a look, it sure looks like a bug.
can I see the rewriterule you are using?

Oct 22, 2006 at 9:38 AM
Possible patch here (OnAuthComplete and OnUrlMap modified):

// Prevents the incorrect use of OriginalUrl and RequestMethod in OnLog()
// preserving PhysicalPath (from OnUrlMap()).
if (pfc!=NULL && pfc ->pFilterContext !=NULL)
IirfRequestContext * ctx = (IirfRequestContext*) pfc ->pFilterContext;
dwRetval = DoRewrites(pfc, pACI);
return dwRetval;

if (pfc!=NULL)
IirfRequestContext * ctx;
if (pfc->pFilterContext==NULL && !InitCustomFilterContext(pfc))
ctx= (IirfRequestContext *) pfc->pFilterContext;
int len= strlen(pUM->pszPhysicalPath) +1; // less than or equal to pUM->cbPathBuff.
if (ctx->PhysicalPath!=NULL)
int len2=strlen(ctx->PhysicalPath) +1;
if (len2<len)
// Created memory if there is no capacity to reuse the existing…
ctx->PhysicalPath= (char *) pfc->AllocMem(pfc, len, 0);
else if (len2==len && strcmp(pUM->pszPhysicalPath,ctx->PhysicalPath)==0)
// They are equal. No copy…
ctx->PhysicalPath= (char *) pfc->AllocMem(pfc, len, 0);

if ( ctx->PhysicalPath == NULL ) {
LogMsg(1, "Error Allocating memory for Physical Path.");
if ( config->LogLevel >= 4 ) {
char * formatString= "OnUrlMap: storing physical path (%s), in ptr (0x%08x)";
int n= len + strlen(formatString) + 8;
char * MsgBuffer = malloc(n+1);
if (MsgBuffer==NULL)
LogMsg(4, "OnUrlMap: storing physical path ...");
else {
sprintf_s(MsgBuffer, n, formatString,
pUM->pszPhysicalPath, ctx->PhysicalPath);
LogMsg(4, MsgBuffer);
strcpy_s(ctx->PhysicalPath, len, pUM->pszPhysicalPath);
else LogMsg(1, "OnUrlMap: no RequestContext.");
Oct 22, 2006 at 4:24 PM

(First, excellent plugin, many thanks)

It's not "every other time" it's more like "90% doesn't work.."

My bit of rewriter is really really simple:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog/(.*)$ /blog/index.php/$1 L


My log file has many more errors than not.

I'll compile the suggested patch right now and see how that goes - this does compile on VS IDE 2005, right?

*Hopes really hard!
Oct 22, 2006 at 6:30 PM
It compiles on VS 2k5, but it doesn't run on my server because the runtimes aren't there.

What compiler do you use, Cheeso?
Oct 26, 2006 at 6:32 PM

Sorry about the delay, I've been caught up with some other issues.

The rule is:

    1. Products ##
RewriteCond %{HTTP_URL} (/|\.htm/^.*)$ I
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /products/(\w-)(/(\w-))?/?\??(.*)$ /products/viewProduct.aspx?base_url=$1&section=$3&url=/products/$1/&$4 U,L

Oct 26, 2006 at 11:01 PM

To compile IIRF, I use the VC8 compiler from VS 2005. I have also test compiled it with the VC8 compiler from VC 2005 Express (the free tool).

Oct 27, 2006 at 12:26 AM
Rdlejo, thanks for the suggested fix. I haven't tested it extensively. Eric and ComputerGuru, Can you try out this version:


it includes rdlejo's fix and some other re-factoring.
Oct 27, 2006 at 9:55 PM
It's appending "1" to the end of any rewritten URIs in the new build.

For instance, a completely blank .ini file with only this entry:

RewriteRule ^/myfile/(.*)$ /$1 L,R

go to http://myhost/myfile/me -> http://myhost/me1


*starts comparing source code.
This is the direct DLL you provided, I haven't compiled it myself yet.

Thanks for the help though.. and for this excellent dll.
Oct 27, 2006 at 10:12 PM
When I try building it myself it goes through, but when I restart the IIS service on my server I get this message in the error log and IIS crashes:

Activation context generation failed for "C:\IIRF\IIRF.dll". Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.363" could not be found. Please use sxstrace.exe for detailed diagnosis.

I build it with VC++ 8.0 as well....
Oct 31, 2006 at 9:12 PM
I think you are running into this problem:


Oct 31, 2006 at 9:13 PM
Ahh, yes I noticed that myself after some further testing, so I uploaded a corrected v1.2.11a to the download site, I believe it should be fixed now.

Oct 31, 2006 at 9:55 PM
I've run version 1.2.11a through my system. It's running into a new problem that wasn't in the prior version. For my RegExp replacements when I want to get a capture ($1,$2,$3) I keep running into the issue where it'll capture the text I want it to, and then it dumps it with the number behind it.

RewriteRule /(\w-_/)/?\??(.)$ /products/viewCategory.aspx?base_url=$1&$2 U,L

Input: /kits/?show
Output: /products/viewCategory.aspx?base_url=kits1&show2 (notice: kits1&show2, I want kits&show)

This doesn't happen in the prior version, it just seems to happen in this new version.

Oct 31, 2006 at 10:07 PM
Double checked and it happens in the newer v.1.2.11a compile as well.

Oct 31, 2006 at 10:45 PM
very clear. I will have another look.
Oct 31, 2006 at 11:48 PM
Alright, I finally got it to compile and run.

That CRT error was easy, just had to google. Thanks though.

The REAL problem was with the .DEF file - it's not mentioned anywhere in the documentation as far as I can see. It took a long time for me to find a reference to its existence online, but with that I was able to do it.

I'm going to compile the fix now - but I'll use the .10 codebase that doesn't have any of the rewrite problems with integers - going to see if it works.
Oct 31, 2006 at 11:59 PM
Damn it!

I applied the patch to the untouched .10 codebase - no luck.

It seems that the work:fail ratio is better (placebo?), but it definitely still fails to check all contents.

My version: http://neosmart.ath.cx/IsapiRewrite4.rar

Note: It has zero optimizations ATM, it's 2 am and I have to be up in 3 hours - will re-upload with optimizations tomorrow.

If the onurlauthcomplete and onurlmap functions aren't the problem, do you have any idea what else could be?
It's definitely a bug: keeping the F5 button pressed long enough will result in the entry being properly parsed...
Nov 1, 2006 at 12:24 AM
clarification: i did manage to compile and run the code. my compiling works great now (after the .DEF file stuff).

My compile is .10 + the patch mentioned above. It doesn't have any of the refactoring and improvements done in the .11 build - and it also doesn't have the number-appended-to-url bug though either.

The patch mentioned above does NOT fix the problem. IT is something else.
Nov 1, 2006 at 12:27 AM
I will have a look but can't tonight, other commitments....
Nov 5, 2006 at 8:23 PM
Cheeso, do you have an estimate (even if it's very rough) on when IIRF v1.2.11 (or whatever the next stable version number is) will be released? Because of the issues with the -d and -f flags mentioned here, I plan to hold off on using IIRF until the next version is released. If you aren't sure when it will come out, that's fine, but I just thought I'd check. :)
Nov 27, 2006 at 6:53 PM
Any word on this yet, Dino?