Problem with rule depth

Topics: User Forum
Dec 20, 2007 at 9:49 PM
Edited Dec 20, 2007 at 9:56 PM
Hi,

I need to be able to access a URL without the ".aspx".

e.g. /pks/lookup?key=value should redirect to /pks/lookup.aspx?key=value

I thought I had cracked it with the following rule

RewriteRule ^/pks/lookup(.+)$ /pks/lookup.aspx$1

Unfortunately I have the following problem:
Thu Dec 20 22:00:51 2007 - HttpFilterProc SF_NOTIFY_URL_MAP
Thu Dec 20 22:00:51 2007 - HttpFilterProc SF_NOTIFY_AUTH_COMPLETE
Thu Dec 20 22:00:51 2007 - DoRewrites
Thu Dec 20 22:00:51 2007 - New Url: '/pks/lookup?helloworld'
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=0)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 27): /pks/lookup.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=1)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 32): /pks/lookup.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=2)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 37): /pks/lookup.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=3)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 42): /pks/lookup.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=4)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 47): /pks/lookup.aspx.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=5)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 52): /pks/lookup.aspx.aspx.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=6)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 57): /pks/lookup.aspx.aspx.aspx.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=7)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 62): /pks/lookup.aspx.aspx.aspx.aspx.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - ApplyRules (depth=8)
Thu Dec 20 22:00:51 2007 - Rule 1 : 2 matches
Thu Dec 20 22:00:51 2007 - Result (length 67): /pks/lookup.aspx.aspx.aspx.aspx.aspx.aspx.aspx.aspx.aspx?helloworld
Thu Dec 20 22:00:51 2007 - Iteration stopped; reached limit of 8 cycles.
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - ApplyRules: returning 1
Thu Dec 20 22:00:51 2007 - Rewrite Url to: '/pks/lookup.aspx.aspx.aspx.aspx.aspx.aspx.aspx.aspx.aspx?helloworld'
I am certainly no expert with regexs. Could anyone let me know why ".aspx" is being repeated and how I can stop it?

(I tried adding "IterationLimit 1" but it still adds one extra ".aspx"!)

Many thanks,

Tom
Dec 26, 2007 at 4:54 AM
Edited Dec 26, 2007 at 4:54 AM
Hi Tom,

I found this in the readme and thought you might try this for your problem, I am no pro either but you could try the [L] on the end of your rule. This is from the manual:

[L]
----
This flag tells IIRF to process no more patterns if the current
one matches. The default behavior is to recurse, until no match
is found, or until the iteration limit is reached.
Dec 26, 2007 at 2:55 PM
Thanks ievolve,

I actually managed to tweak my regex so that it worked. Am now using following:
RewriteRule  ^/pks/lookup\?(.+)	      /pks/lookup.aspx?$1

However, the L option may well be useful for something else I am trying to do, so many thanks for drawing my attention to it!