Name
Translate Name
Synopsis
int module_translate(request_rec *pReq)
This function’s task is to
translate the URL in a request into a filename. The end result of its
deliberations should be placed in
pReq->filename
. It should return
OK
, DECLINED
, or a status code.
The first module that doesn’t return
DECLINED
is assumed to have done the job, and no
further modules are called. Since the order in which modules are
called is not defined, it is a good thing if the URLs handled by the
modules are mutually exclusive. If all modules return
DECLINED
, a configuration error has occurred.
Obviously, the function is likely to use the per-directory and
per-server configurations (but note that at this stage, the
per-directory configuration refers to the root configuration of the
current server) to determine whether it should handle the request, as
well as the URL itself (in pReq->uri
). If a
status is returned, the appropriate headers for the response should
also be set in pReq->headers_out
.
Naturally enough, Example 21-14 (1.3 and 2.0) comes from mod_alias.c:
Example
static char *try_alias_list(request_rec *r, array_header *aliases, int doesc, int *status) { alias_entry *entries = (alias_entry *) aliases->elts; regmatch_t regm[10]; char *found = NULL; int i; for (i = 0; i < aliases->nelts; ++i) { alias_entry *p = &entries[i]; int l; if (p->regexp) { if (!ap_regexec(p->regexp, r->uri, p->regexp->re_nsub + 1, regm, 0)) { if (p->real) { found = ap_pregsub(r->pool, p->real, ...
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.