Name
Per-Directory Merger
Synopsis
void *module_dir_merge(pool *pPool, void *base_conf, void *new_conf)
Like the per-server merger, this
is called once for each virtual host (not for each directory). It is
handed the per-server document root per-directory Config (that is,
the one that was created with a NULL
directory
name).
Whenever a request is processed, this function merges all relevant
<Directory>
sections and then merges
.htacess files (interleaved, starting at the
root and working downward), then <File>
and
<Location>
sections, in that order.
Unlike the per-server merger, per-directory merger is called as the
server runs, possibly with different combinations of directory,
location, and file configurations for each request, so it is
important that it copies the configuration (in
new_conf
) if it is going to change it.
Now the reason we chose mod_rewrite.c for the per-directory creator becomes apparent, as it is a little more interesting than most. See Example 21-5.
Example
static void *config_perdir_merge(pool *p, void *basev, void *overridesv) { rewrite_perdir_conf *a, *base, *overrides; a = (rewrite_perdir_conf *)pcalloc(p, sizeof(rewrite_perdir_conf)); base = (rewrite_perdir_conf *)basev; overrides = (rewrite_perdir_conf *)overridesv; a->state = overrides->state; a->options = overrides->options; a->directory = overrides->directory; a->baseurl = overrides->baseurl; if (a->options & OPTION_INHERIT) { a->rewriteconds = append_arrays(p, overrides->rewriteconds, ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.