Lines 195-200
static const char* really_last_key = "re
Link Here
|
195 |
#define OPTION_INHERIT_DOWN 1<<6 |
195 |
#define OPTION_INHERIT_DOWN 1<<6 |
196 |
#define OPTION_INHERIT_DOWN_BEFORE 1<<7 |
196 |
#define OPTION_INHERIT_DOWN_BEFORE 1<<7 |
197 |
#define OPTION_IGNORE_INHERIT 1<<8 |
197 |
#define OPTION_IGNORE_INHERIT 1<<8 |
|
|
198 |
#define OPTION_URLPATH_LOCATION 1<<9 |
198 |
|
199 |
|
199 |
#ifndef RAND_MAX |
200 |
#ifndef RAND_MAX |
200 |
#define RAND_MAX 32767 |
201 |
#define RAND_MAX 32767 |
Lines 2948-2953
static const char *cmd_rewriteoptions(cm
Link Here
|
2948 |
else if (!strcasecmp(w, "mergebase")) { |
2949 |
else if (!strcasecmp(w, "mergebase")) { |
2949 |
options |= OPTION_MERGEBASE; |
2950 |
options |= OPTION_MERGEBASE; |
2950 |
} |
2951 |
} |
|
|
2952 |
else if (!strcasecmp(w, "urlpathlocation")) { |
2953 |
options |= OPTION_URLPATH_LOCATION; |
2954 |
} |
2951 |
else { |
2955 |
else { |
2952 |
return apr_pstrcat(cmd->pool, "RewriteOptions: unknown option '", |
2956 |
return apr_pstrcat(cmd->pool, "RewriteOptions: unknown option '", |
2953 |
w, "'", NULL); |
2957 |
w, "'", NULL); |
Lines 4166-4180
static int apply_rewrite_rule(rewriterul
Link Here
|
4166 |
} |
4170 |
} |
4167 |
|
4171 |
|
4168 |
/* If this rule is explicitly forced for HTTP redirection |
4172 |
/* If this rule is explicitly forced for HTTP redirection |
4169 |
* (`RewriteRule .. .. [R]') then force an external HTTP |
4173 |
* (`RewriteRule .. .. [R]') then force an external HTTP redirect. |
4170 |
* redirect. But make sure it is a fully-qualified URL. (If |
4174 |
* |
4171 |
* not it is qualified with ourself). |
4175 |
* Depending on RewriteOptions URLPathLocation: |
|
|
4176 |
* |
4177 |
* not set (default): Make sure, redirect location is |
4178 |
* a fully-qualified URL. If not it is qualified with ourself. |
4179 |
* |
4180 |
* set: If redirect to a URL-Path is requested, no modification |
4181 |
* is done to the path itself. If a fully-qualified URL is given, |
4182 |
* it is processed as if URLPathLocation is not set. |
4183 |
* URL-Paths as header "Location:" are allowed since RFC 7231 7.1.2. |
4172 |
*/ |
4184 |
*/ |
4173 |
if (p->flags & RULEFLAG_FORCEREDIRECT) { |
4185 |
if (p->flags & RULEFLAG_FORCEREDIRECT) { |
4174 |
fully_qualify_uri(r); |
4186 |
rewrite_server_conf *sconf |
4175 |
|
4187 |
= ap_get_module_config(r->server->module_config, &rewrite_module); |
4176 |
rewritelog((r, 2, ctx->perdir, "explicitly forcing redirect with %s", |
4188 |
rewrite_perdir_conf *dconf |
4177 |
r->filename)); |
4189 |
= ap_get_module_config(r->per_dir_config, &rewrite_module); |
|
|
4190 |
if (sconf->options & OPTION_URLPATH_LOCATION |
4191 |
|| dconf->options & OPTION_URLPATH_LOCATION) { |
4192 |
rewritelog((r, 2, ctx->perdir, |
4193 |
"explicitly forcing URLPathLocation redirect with %s", |
4194 |
r->filename)); |
4195 |
} else { |
4196 |
fully_qualify_uri(r); |
4197 |
rewritelog((r, 2, ctx->perdir, |
4198 |
"explicitly forcing redirect with %s", |
4199 |
r->filename)); |
4200 |
} |
4178 |
|
4201 |
|
4179 |
r->status = p->forced_responsecode; |
4202 |
r->status = p->forced_responsecode; |
4180 |
return 1; |
4203 |
return 1; |
Lines 4634-4640
static int hook_uri2file(request_rec *r)
Link Here
|
4634 |
r->filename)); |
4657 |
r->filename)); |
4635 |
return OK; |
4658 |
return OK; |
4636 |
} |
4659 |
} |
4637 |
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0) { |
4660 |
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0 |
|
|
4661 |
|| conf->options & OPTION_URLPATH_LOCATION) { |
4638 |
int n; |
4662 |
int n; |
4639 |
|
4663 |
|
4640 |
/* it was finally rewritten to a remote URL */ |
4664 |
/* it was finally rewritten to a remote URL */ |
Lines 4642-4648
static int hook_uri2file(request_rec *r)
Link Here
|
4642 |
if (rulestatus != ACTION_NOESCAPE) { |
4666 |
if (rulestatus != ACTION_NOESCAPE) { |
4643 |
rewritelog((r, 1, NULL, "escaping %s for redirect", |
4667 |
rewritelog((r, 1, NULL, "escaping %s for redirect", |
4644 |
r->filename)); |
4668 |
r->filename)); |
4645 |
r->filename = escape_absolute_uri(r->pool, r->filename, skip); |
4669 |
if (conf->options & OPTION_URLPATH_LOCATION |
|
|
4670 |
&& !is_absolute_uri(r->filename, NULL)) { |
4671 |
r->filename = ap_escape_uri(r->pool, r->filename); |
4672 |
} else { |
4673 |
r->filename = escape_absolute_uri(r->pool, r->filename, skip); |
4674 |
} |
4646 |
} |
4675 |
} |
4647 |
|
4676 |
|
4648 |
/* append the QUERY_STRING part */ |
4677 |
/* append the QUERY_STRING part */ |
Lines 4884-4890
static int hook_fixup(request_rec *r)
Link Here
|
4884 |
"%s [OK]", r->filename)); |
4913 |
"%s [OK]", r->filename)); |
4885 |
return OK; |
4914 |
return OK; |
4886 |
} |
4915 |
} |
4887 |
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0) { |
4916 |
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0 |
|
|
4917 |
|| dconf->options & OPTION_URLPATH_LOCATION) { |
4888 |
/* it was finally rewritten to a remote URL */ |
4918 |
/* it was finally rewritten to a remote URL */ |
4889 |
|
4919 |
|
4890 |
/* because we are in a per-dir context |
4920 |
/* because we are in a per-dir context |
Lines 4938-4944
static int hook_fixup(request_rec *r)
Link Here
|
4938 |
if (rulestatus != ACTION_NOESCAPE) { |
4968 |
if (rulestatus != ACTION_NOESCAPE) { |
4939 |
rewritelog((r, 1, dconf->directory, "escaping %s for redirect", |
4969 |
rewritelog((r, 1, dconf->directory, "escaping %s for redirect", |
4940 |
r->filename)); |
4970 |
r->filename)); |
4941 |
r->filename = escape_absolute_uri(r->pool, r->filename, skip); |
4971 |
if (dconf->options & OPTION_URLPATH_LOCATION |
|
|
4972 |
&& !is_absolute_uri(r->filename, NULL)) { |
4973 |
r->filename = ap_escape_uri(r->pool, r->filename); |
4974 |
} else { |
4975 |
r->filename = escape_absolute_uri(r->pool, r->filename, skip); |
4976 |
} |
4942 |
} |
4977 |
} |
4943 |
|
4978 |
|
4944 |
/* append the QUERY_STRING part */ |
4979 |
/* append the QUERY_STRING part */ |