diff options
author | Stefan Fritsch <sf@apache.org> | 2011-06-05 23:33:12 +0200 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2011-06-05 23:33:12 +0200 |
commit | feca55db60704131ac4584ceb60a6cf17a97b2ac (patch) | |
tree | 2f3d166711f83a6f3d40c3dc3f7ebb84fa4303d9 /server/core.c | |
parent | - Add <ElseIf> and <Else> to complement <If> sections. These are both easier (diff) | |
download | apache2-feca55db60704131ac4584ceb60a6cf17a97b2ac.tar.xz apache2-feca55db60704131ac4584ceb60a6cf17a97b2ac.zip |
- 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 'server/core.c')
-rw-r--r-- | server/core.c | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/server/core.c b/server/core.c index 6566bef1fb..fdeceb79c5 100644 --- a/server/core.c +++ b/server/core.c @@ -722,12 +722,51 @@ AP_DECLARE(int) ap_satisfies(request_rec *r) AP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */ { - core_server_config *conf; + core_server_config *sconf; + core_request_config *rconf = ap_get_module_config(r->request_config, + &core_module); + if (rconf->document_root) + return rconf->document_root; + sconf = ap_get_module_config(r->server->module_config, &core_module); + return sconf->ap_document_root; +} - conf = (core_server_config *)ap_get_module_config(r->server->module_config, - &core_module); +AP_DECLARE(const char *) ap_context_prefix(request_rec *r) +{ + core_request_config *conf = ap_get_module_config(r->request_config, + &core_module); + if (conf->context_prefix) + return conf->context_prefix; + else + return ""; +} - return conf->ap_document_root; +AP_DECLARE(const char *) ap_context_document_root(request_rec *r) +{ + core_request_config *conf = ap_get_module_config(r->request_config, + &core_module); + if (conf->context_document_root) + return conf->context_document_root; + else + return ap_document_root(r); +} + +AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root) +{ + core_request_config *conf = ap_get_module_config(r->request_config, + &core_module); + conf->document_root = document_root; +} + +AP_DECLARE(void) ap_set_context_info(request_rec *r, const char *context_prefix, + const char *context_document_root) +{ + core_request_config *conf = ap_get_module_config(r->request_config, + &core_module); + if (context_prefix) + conf->context_prefix = context_prefix; + if (context_document_root) + conf->context_document_root = context_document_root; } /* Should probably just get rid of this... the only code that cares is |