--- mod_rewrite.c.orig 2005-05-25 12:05:06.000000000 +0200 +++ mod_rewrite.c 2006-03-09 22:36:12.470704000 +0100 @@ -1691,6 +1691,7 @@ "[INTERNAL REDIRECT]", dconf->directory, r->filename); r->filename = apr_pstrcat(r->pool, "redirect:", r->filename, NULL); r->handler = "redirect-handler"; + apr_table_unset(r->notes,"substapplied"); return OK; } } @@ -1874,6 +1875,7 @@ r->filename = apr_pstrcat(r->pool, "forbidden:", r->filename, NULL); changed = ACTION_NORMAL; + apr_table_unset(r->notes,"substapplied"); break; } @@ -1885,6 +1887,7 @@ rewritelog(r, 2, "forcing '%s' to be gone", r->filename); r->filename = apr_pstrcat(r->pool, "gone:", r->filename, NULL); changed = ACTION_NORMAL; + apr_table_unset(r->notes,"substapplied"); break; } @@ -1893,6 +1896,7 @@ * last-rule and new-round flags. */ if (p->flags & RULEFLAG_PROXY) { + apr_table_unset(r->notes,"substapplied"); break; } if (p->flags & RULEFLAG_LASTRULE) { @@ -1966,9 1970,15 @@ /* * Add (perhaps splitted away) PATH_INFO postfix to URL to - * make sure we really match against the complete URL. + * make sure we really match against the complete URL, but skip + * if a substitution already occurred */ - if (perdir != NULL && r->path_info != NULL && r->path_info[0] != '\0') { + if (apr_table_get(r->notes,"substapplied") && perdir != NULL && + r->path_info != NULL && r->path_info[0] != '\0') { + rewritelog(r, 5, "[per-dir %s] ignoring path info postfix '%s', substitution already occurred: %s", + perdir, r->path_info, uri); + } + else if (perdir != NULL && r->path_info != NULL && r->path_info[0] != '\0') { rewritelog(r, 3, "[per-dir %s] add path info postfix: %s -> %s%s", perdir, uri, uri, r->path_info); uri = apr_pstrcat(r->pool, uri, r->path_info, NULL); @@ -2158,6 +2168,7 @@ rewritelog(r, 2, "rewrite %s -> %s", uri, newuri); } else { + apr_table_set(r->notes,"substapplied","true"); rewritelog(r, 2, "[per-dir %s] rewrite %s -> %s", perdir, uri, newuri); }