RewriteRule's skip flag [S=#] is a relative goto. It would be very nice to have the possibility of negative arguments for it. So [S=1] means skip the next rule (already exists), [S=0] means use the next rule (a no-op in other words), [S=-1] means loop/reevaluate this rule, [S=-2] means goto the previous rule, etc., and [N] means goto the first rule (already exists). This would cut out a possibly large amount of unnecessary testing. Here's an actual use possibility: # Deepest directory finder: initialization # At the end, Pfx will have the shallowest non directory RewriteRule ^(/[^/]*)(.*)$ - [E=Pfx:$1,E=Sfx:$2] # Deepest directory finder: loop RewriteCond %{DOCUMENT_ROOT}%{ENV:Pfx}/ -d RewriteCond %{ENV:Sfx} ^(/[^/]*)(.*)$ RewriteRule . - [E=Pfx:%{ENV:Pfx}%1,E=Sfx:%2,S=-1] Of course currently I have to use an N in place of that S=-1 and put in a check for when to run the above at the top of the rewrite rules, which means that the check gets evaluated on every request and every [N] Csaba Gabor from Vienna
Created attachment 19468 [details] proposed enhancement patch against trunk
Please test the proposed patch. Be aware of bug 38642 (directory context: continuously adding of path-info to already substituted paths) not to produce an infinite loop when using negative arguments.
Created attachment 19469 [details] proposed enhancement