When using `mod_rewrite`, the `RewriteMap` directive defines a "Rewriting Map" which can be used inside rule substitution strings to insert or substitute fields with a key/value lookup.
The RewriteMap
directive defines a Rewriting Map which can be used inside rule substitution strings by the mapping-functions to insert/substitute fields through a key lookup. The source of this lookup can be of various types.
The MapName
is the name of the map and will be used to specify a mapping-function for the substitution strings of a rewriting rule via one of the following constructs:
${ MapName : LookupKey }
${ MapName : LookupKey | DefaultValue }
For example, you might define a RewriteMap
and RewriteRule
as follows:
RewriteMap examplemap txt:/path/to/file/map.txt
RewriteRule ^/ex/(.*) /ex/index.php?path=${examplemap:$1}
If the map file contains a line reading foo bar
, then that rule would rewrite a request for /ex/foo
to /ex/index.php?path=bar
.
Documentation: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap