</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;
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->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;
}
return PREGSUB_ERROR;
}
- if (dirconf->alias_fake) {
+ if (dirconf->alias_fake && dirconf->alias_preserve_path == ALIAS_FLAG_ON) {
int l;
l = alias_matches(r->uri, dirconf->alias_fake);
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}
};