Index: modules/mappers/mod_rewrite.c =================================================================== --- modules/mappers/mod_rewrite.c (revision 614276) +++ modules/mappers/mod_rewrite.c (working copy) @@ -147,6 +147,7 @@ #define RULEFLAG_NOSUB 1<<12 #define RULEFLAG_STATUS 1<<13 #define RULEFLAG_ESCAPEBACKREF 1<<14 +#define RULEFLAG_ITERATE 1<<15 /* return code of the rewrite rule * the result may be escaped - or not @@ -3261,6 +3262,16 @@ } break; + case 'i': + case 'I': + if (!*key || !strcasecmp(key, "terate")) { /* iterate */ + cfg->flags |= RULEFLAG_ITERATE; + } + else { + ++error; + } + break; + case 'l': case 'L': if (!*key || !strcasecmp(key, "ast")) { /* last */ @@ -3936,10 +3947,20 @@ rc = apply_rewrite_rule(p, ctx); if (rc) { - /* Regardless of what we do next, we've found a match. Check to see - * if any of the request header fields were involved, and add them - * to the Vary field of the response. + /* Regardless of what we do next, we've found a match. + * Iterate over the rule as long as it matches, + * if the iteration flag has been set. + * Don't detroy return code from first match. */ + if (p->flags & RULEFLAG_ITERATE) { + while(apply_rewrite_rule(p, ctx)) { + } + } + + /* + * Check to see if any of the request header fields were + * involved, and add them to the Vary field of the response. + */ if (ctx->vary) { apr_table_merge(r->headers_out, "Vary", ctx->vary); } Index: docs/manual/mod/mod_rewrite.xml =================================================================== --- docs/manual/mod/mod_rewrite.xml (revision 614277) +++ docs/manual/mod/mod_rewrite.xml (working copy) @@ -1318,6 +1318,12 @@ inside the mapped directory to have a handler of ``cgi-script''. +
+ 'iterate|I' + (iterate while match)
+ Iterate the rewrite rule as long as the RewriteCond applies + and the Pattern matches.
+
'last|L' (last rule)
Stop the rewriting process here and don't apply any more rewrite rules. This corresponds