diff options
author | Stefan Fritsch <sf@apache.org> | 2011-06-05 21:33:12 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2011-06-05 21:33:12 +0000 |
commit | feca55db60704131ac4584ceb60a6cf17a97b2ac (patch) | |
tree | 2f3d166711f83a6f3d40c3dc3f7ebb84fa4303d9 /modules/mappers/mod_alias.c | |
parent | 93623482e38ff281785b3c2c5b292f5c87afef4f (diff) | |
download | httpd-feca55db60704131ac4584ceb60a6cf17a97b2ac.tar.gz |
- Introduce concept of context prefix (which is an URL prefix)
and context document root (which is the file system directory that
this URL prefix is mapped to). This generalization of the document
root makes it easier for scripts to create self-referential URLs and
to find their files.
- Expose CONTEXT_DOCUMENT_ROOT and CONTEXT_PREFIX as envvars, in mod_rewrite,
and in ap_expr.
- Make mod_alias and mod_userdir set the context information.
- Allow to override the document root on a per-request basis. This allows
mass vhosting modules to set DOCUMENT_ROOT correctly.
- Make mod_vhost_alias set the per-request document root
PR: 26052, 46198, 49705
Remaining tasks:
- Use the context document root & prefix in mod_rewrite to make RewriteBase
unneccessary in many cases. Do this without breaking compatibility.
- Write docs.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1132494 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/mappers/mod_alias.c')
-rw-r--r-- | modules/mappers/mod_alias.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/modules/mappers/mod_alias.c b/modules/mappers/mod_alias.c index dc40b67086..18b48f557e 100644 --- a/modules/mappers/mod_alias.c +++ b/modules/mappers/mod_alias.c @@ -334,7 +334,7 @@ static int alias_matches(const char *uri, const char *alias_fakename) } static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, - int doesc, int *status) + int is_redir, int *status) { alias_entry *entries = (alias_entry *) aliases->elts; ap_regmatch_t regm[AP_MAX_REG_MATCH]; @@ -350,21 +350,34 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, if (alias->real) { found = ap_pregsub(r->pool, alias->real, r->uri, AP_MAX_REG_MATCH, regm); - if (found && doesc) { - apr_uri_t uri; - apr_uri_parse(r->pool, found, &uri); - /* Do not escape the query string or fragment. */ - found = apr_uri_unparse(r->pool, &uri, - APR_URI_UNP_OMITQUERY); - found = ap_escape_uri(r->pool, found); - if (uri.query) { - found = apr_pstrcat(r->pool, found, "?", - uri.query, NULL); - } - if (uri.fragment) { - found = apr_pstrcat(r->pool, found, "#", - uri.fragment, NULL); - } + if (found) { + if (is_redir) { + apr_uri_t uri; + apr_uri_parse(r->pool, found, &uri); + /* Do not escape the query string or fragment. */ + found = apr_uri_unparse(r->pool, &uri, + APR_URI_UNP_OMITQUERY); + found = ap_escape_uri(r->pool, found); + if (uri.query) { + found = apr_pstrcat(r->pool, found, "?", + uri.query, NULL); + } + if (uri.fragment) { + found = apr_pstrcat(r->pool, found, "#", + uri.fragment, NULL); + } + } + else { + int pathlen = strlen(found) - + (strlen(r->uri + regm[0].rm_eo)); + AP_DEBUG_ASSERT(pathlen >= 0); + AP_DEBUG_ASSERT(pathlen <= strlen(found)); + ap_set_context_info(r, + apr_pstrmemdup(r->pool, r->uri, + regm[0].rm_eo), + apr_pstrmemdup(r->pool, found, + pathlen)); + } } } else { @@ -377,7 +390,8 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, l = alias_matches(r->uri, alias->fake); if (l > 0) { - if (doesc) { + ap_set_context_info(r, alias->fake, alias->real); + if (is_redir) { char *escurl; escurl = ap_os_escape_path(r->pool, r->uri + l, 1); @@ -398,7 +412,7 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases, * canonicalized. After I finish eliminating os canonical. * Better fail test for ap_server_root_relative needed here. */ - if (!doesc) { + if (!is_redir) { found = ap_server_root_relative(r->pool, found); } if (found) { |