Name
RewriteMap
Synopsis
RewriteMap mapname {txt,dbm,prg,rnd,int}: filename Server config, virtual host
Defines an external mapname
file that
inserts substitution strings through key lookup.Keys may be stored in
a variety of formats, described as follows. The module passes
mapname
a query in
the form:
$(mapname
:Lookupkey
|DefaultValue
)
If the Lookupkey
value is not found,
DefaultValue
is returned.
The type of mapname
must be specified by
the next argument:
-
txt
Indicates plain-text format — that is, an ASCII file with blank lines, comments that begin with
#
, or useful lines, in the format:MatchingKey
SubstituteValue
-
dbm
Indicates DBM hashfile format — that is, a binary NDBM (the “new” dbm interface, now about 15 years old, also used for dbm auth) file containing the same material as the plain-text format file. You create it with any ndbm tool or by using the Perl script dbmmanage from the support directory of the Apache distribution.
-
prg
Indicates program format — that is, an executable (a compiled program or a CGI script) that is started by Apache. At each lookup, it is passed the key as a string terminated by newline on
stdin
and returns the substitution value, or the wordNULL
if lookup fails, in the same way onstdout
. The manual gives two warnings:Keep the program or script simple because if it hangs, it hangs the Apache server.
Don’t use buffered I/O on
stdout
because it causes a deadlock. In C, use:setbuf(stdout,NULL)
In Perl, use:
select(STDOUT); $|=1;]
-
rnd
Indicates ...
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.