Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge r1919860 from trunk #473

Open
wants to merge 1 commit into
base: 2.4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes-entries/rewrite-perdir-unc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*) mod_rewrite: Don't require [UNC] flag to preserve a leading //
added by applying the perdir prefix to the substitution.
[Ruediger Pluem, Eric Covener]
5 changes: 4 additions & 1 deletion modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4284,6 +4284,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
char *newuri = NULL;
request_rec *r = ctx->r;
int is_proxyreq = 0;
int prefix_added = 0;

ctx->uri = r->filename;

Expand Down Expand Up @@ -4444,6 +4445,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
rewritelog((r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
newuri, ctx->perdir, newuri));
newuri = apr_pstrcat(r->pool, ctx->perdir, newuri, NULL);
prefix_added = 1;
}
else if (!(p->flags & (RULEFLAG_PROXY | RULEFLAG_FORCEREDIRECT))) {
/* Not an absolute URI-path and the scheme (if any) is unknown,
Expand All @@ -4457,6 +4459,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
newuri, newuri));

newuri = apr_pstrcat(r->pool, "/", newuri, NULL);
prefix_added = 1;
}
}

Expand Down Expand Up @@ -4537,7 +4540,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
return RULE_RC_MATCH;
}

if (!(p->flags & RULEFLAG_UNC)) {
if (!((p->flags & RULEFLAG_UNC) || prefix_added)) {
/* merge leading slashes, unless they were literals in the sub */
if (!AP_IS_SLASH(p->output[0]) || !AP_IS_SLASH(p->output[1])) {
while (AP_IS_SLASH(r->filename[0]) &&
Expand Down
Loading