PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- *) mod_alias: Add AliasPreservePath directive to map the full path after the
- alias in a location. Requires r1861542 / r1861569 above.
- Trunk version of patch:
- https://svn.apache.org/r1909137
- https://svn.apache.org/r1911067
- Backport version for 2.4.x of patch:
- https://svn.apache.org/repos/asf/httpd/httpd/patches/2.4.x/alias-preserve-path3.diff
- +1: minfrin, rpluem, covener
-
*) mod_ssl: Silence info log message "SSL Library Error: error:0A000126:
SSL routines::unexpected eof while reading" when using
OpenSSL 3 by setting SSL_OP_IGNORE_UNEXPECTED_EOF if
</LocationMatch>
</highlight>
+ <p>Note that when the <directive>AliasPreservePath</directive>
+ directive is on, the full path is mapped to the destination. When
+ the directive is off, all URLs are mapped to the single target
+ URL.</p>
+
+ <highlight language="config">
+# /files/foo and /files/bar mapped to /ftp/pub/files/foo and /ftp/pub/files/bar
+<Location "/files">
+ AliasPreservePath on
+ Alias "/ftp/pub/files"
+</Location>
+# /errors/foo and /errors/bar mapped to /var/www/errors.html
+<Location "/errors">
+ AliasPreservePath off
+ Alias "/var/www/errors.html"
+</Location>
+ </highlight>
+
</usage>
</directivesynopsis>
</usage>
</directivesynopsis>
+<directivesynopsis>
+<name>AliasPreservePath</name>
+<description>Map the full path after the alias in a location.</description>
+<syntax>AliasPreservePath OFF|ON</syntax>
+<default>AliasPreservePath OFF</default>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context>
+</contextlist>
+<compatibility>2.5.1 and later</compatibility>
+
+<usage>
+ <p>When using the two parameter version of the
+ <directive>Alias</directive> directive, the full path after the alias
+ is preserved. When using the one parameter version of the
+ <directive>Alias</directive> directive inside a
+ <directive>Location</directive> directive, the full path is dropped,
+ and all URLs are mapped to the target expression.</p>
+
+ <p>To make the one parameter version of the
+ <directive>Alias</directive> directive preserve paths in the same way
+ that the two parameter version of the <directive>Alias</directive>
+ directive, enable this setting.</p>
+
+</usage>
+</directivesynopsis>
</modulesynopsis>
#define ALIAS_FLAG_OFF 0
#define ALIAS_FLAG_ON 1
+#define ALIAS_PRESERVE_PATH_DEFAULT 0
+
typedef struct {
const char *real;
const char *fake;
unsigned int redirect_set:1;
apr_array_header_t *redirects;
const ap_expr_info_t *alias;
+ const char *alias_fake;
char *handler;
const ap_expr_info_t *redirect;
int redirect_status; /* 301, 302, 303, 410, etc */
int allow_relative; /* skip ap_construct_url() */
+ int alias_preserve_path; /* map full path */
} alias_dir_conf;
module AP_MODULE_DECLARE_DATA alias_module;
(alias_dir_conf *) apr_pcalloc(p, sizeof(alias_dir_conf));
a->redirects = apr_array_make(p, 2, sizeof(alias_entry));
a->allow_relative = ALIAS_FLAG_DEFAULT;
+ a->alias_preserve_path = ALIAS_FLAG_DEFAULT;
return a;
}
a->redirects = apr_array_append(p, overrides->redirects, base->redirects);
a->alias = (overrides->alias_set == 0) ? base->alias : overrides->alias;
+ a->alias_fake = (overrides->alias_set == 0) ? base->alias_fake : overrides->alias_fake;
a->handler = (overrides->alias_set == 0) ? base->handler : overrides->handler;
a->alias_set = overrides->alias_set || base->alias_set;
a->allow_relative = (overrides->allow_relative != ALIAS_FLAG_DEFAULT)
? overrides->allow_relative
: base->allow_relative;
+ a->alias_preserve_path = (overrides->alias_preserve_path != ALIAS_FLAG_DEFAULT)
+ ? overrides->alias_preserve_path
+ : base->alias_preserve_path;
+
return a;
}
NULL);
}
+ dirconf->alias_fake = cmd->path;
dirconf->handler = cmd->info;
dirconf->alias_set = 1;
return PREGSUB_ERROR;
}
+ if (dirconf->alias_fake && dirconf->alias_preserve_path == ALIAS_FLAG_ON) {
+ int l;
+
+ l = alias_matches(r->uri, dirconf->alias_fake);
+
+ if (l > 0) {
+ ap_set_context_info(r, dirconf->alias_fake, found);
+ found = apr_pstrcat(r->pool, found, r->uri + l, NULL);
+ }
+ }
+
if (dirconf->handler) { /* Set handler, and leave a note for mod_cgi */
r->handler = dirconf->handler;
apr_table_setn(r->notes, "alias-forced-type", r->handler);
AP_INIT_FLAG("RedirectRelative", ap_set_flag_slot,
(void*)APR_OFFSETOF(alias_dir_conf, allow_relative), OR_FILEINFO,
"Set to ON to allow relative redirect targets to be issued as-is"),
+ AP_INIT_FLAG("AliasPreservePath", ap_set_flag_slot,
+ (void*)APR_OFFSETOF(alias_dir_conf, alias_preserve_path), OR_FILEINFO,
+ "Set to ON to map the full path after the fakename to the realname."),
{NULL}
};