Error with new version (1.2.14)

Topics: Developer Forum, User Forum
Sep 11, 2008 at 7:21 AM
Edited Sep 11, 2008 at 7:23 AM
Yesterday I installed the latest version of the filter (1.2.14). Previously I've used 1.2.12d.

Since this update I get "errors" on the following line:

RewriteRule        ^(/index.*?)(?<!.aspx)(\?.*)?$         $1.aspx$2     [I,L]

With the old version when the url was like /index the filter returned /index.aspx.
With the new version I get the following URL: /index.asp$2.

Offcourse this is not the intention.

In the log file I receive the following message while parsing this url:

GenerateReplacementString: Attention: Either we have a Substring index out of range, or the URL is using escaped chars ($2)
ApplyCaseConversion: after  '/index.aspx$2'
ApplyRules: Result (length 13): /index.aspx$2
ApplyRules: Last if Match
ApplyRules: returning 1
DoRewrites: Rewrite Url to: '/index.aspx$2'

How can I resolve this problem without rewriting all the rules or go back to the previous version? I have a lot of this kind of rules.

Thanks in advance.
Sep 11, 2008 at 1:06 PM
I can see it has something to do with a change made in the code on line 2336.

A check has been made if there are more backreferences as items found (I guess the code will do this).

Is there a workaround for this?
I guess it will not help if I change the DIRECTIVE_COND_SUBSTRING_FLAG directive to another character like #?
Sep 11, 2008 at 8:57 PM

Yes, the nerw version is a bit more strict about replacement string.  You can work around it by re-writing your match pattern.

Instead of


Can you write:


In this case, the second group ($2) captures the query string, starting with a question mark, or, if there is no question mark, then it captures nothing at all. I would say you might want to escape the dots - as they are wildcards. Also you might want to separately capture the extension. So the result might be:

RewriteRule ^(/index)(\.[^?]+)(?<!\.aspx)((\?.+)|())$ $1.aspx$3 

The first capture ($1) is "index" - but you could wildcard this to be something else. The second capture is the extension, including the leading dot. Example: .asp or .php. The third capture is the query string if any, including the leading question-mark.

This will work on 1.2.14 and beyond.

Sep 12, 2008 at 2:34 PM
Cheeso thank you.

The new Rule is not working as it should be, it should rewrite the following urls:

/index                            ==> /index.aspx
/index?nickname=test    ==> /index.aspx?nickname=test

I've changed my ruleset to split the rule into seperate rules, which is working correctly, so I'm not using a difficult rule any more.

Again, thanks for your help (and of course the great product!!!!)
Sep 12, 2008 at 3:32 PM
ok, glad it's working.  I had misunderstood what you wanted.