From: Christophe Jaillet Date: Thu, 14 Apr 2016 09:41:17 +0000 (+0000) Subject: Fix doc as spotted by Mark Brooks in online doc X-Git-Tag: 2.4.21~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00da417b1a71f873c8d3df80b4365fe8b512b3ad;p=apache Fix doc as spotted by Mark Brooks in online doc Synch with trunk (r1468709 and r1481364) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1739042 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/rewritemap.xml b/docs/manual/rewrite/rewritemap.xml index 2c7186645b..c8fcdc2457 100644 --- a/docs/manual/rewrite/rewritemap.xml +++ b/docs/manual/rewrite/rewritemap.xml @@ -84,16 +84,16 @@ RewriteMap MapName MapType:MapSource substituted by DefaultValue or by the empty string if no DefaultValue was specified.

-

For example, you might define a +

For example, you can define a RewriteMap as:

RewriteMap examplemap "txt:/path/to/file/map.txt"

You would then be able to use this map in a RewriteRule as follows:

- + RewriteRule "^/ex/(.*)" "${examplemap:$1}" - +

A default value can be specified in the event that nothing is found in the map:

@@ -117,28 +117,72 @@ once created, in your RewriteRule and may be used, and give examples of each.

+
+ int: Internal Function + +

When a MapType of int is used, the MapSource is one + of the available internal RewriteMap functions. Module authors can provide + additional internal functions by registering them with the + ap_register_rewrite_mapfunc API. + The functions that are provided by default are: +

+ + + +

+ To use one of these functions, create a RewriteMap referencing + the int function, and then use that in your RewriteRule: +

+ +

Redirect a URI to an all-lowercase version of itself

+ + +RewriteMap lc int:tolower +RewriteRule "(.*)" "${lc:$1}" [R] + + + +

Please note that the example offered here is for + illustration purposes only, and is not a recommendation. If you want + to make URLs case-insensitive, consider using + mod_speling instead. +

+
+ +
+
txt: Plain text maps

When a MapType of txt is used, the MapSource is a filesystem path to a - plain-text mapping file, containing space-separated key/value pair - per line. Optionally, a line may be contain a comment, starting with + plain-text mapping file, containing one space-separated key/value pair + per line. Optionally, a line may contain a comment, starting with a '#' character.

-

For example, the following might be valid entries in a map - file.

+

A valid text rewrite map file will have the following syntax:

-

+ # Comment line
MatchingKey SubstValue
MatchingKey SubstValue # comment
-

+

When the RewriteMap is invoked the argument is looked for in the first argument of a line, and, if found, the substitution value is returned.

-

For example, we might use a mapfile to translate product names to +

For example, we can use a mapfile to translate product names to product IDs for easier-to-remember URLs, using the following recipe:

Product to ID configuration

@@ -177,7 +221,7 @@ telephone 328 pattern in order for it to match anything: RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT] - + Cached lookups @@ -199,7 +243,7 @@ RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT] One of these values will be chosen at random if the key is matched.

-

For example, you might use the following map +

For example, you can use the following map file and directives to provide a random load balancing between several back-end servers, via a reverse-proxy. Images are sent to one of the servers in the 'static' pool, while everything @@ -217,8 +261,8 @@ dynamic www5|www6 RewriteMap servers "rnd:/path/to/file/map.txt" -RewriteRule "^/(.*\.(png|gif|jpg))" "http://${servers:static}/$1" [NC,P,L] -RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L] +RewriteRule "^/(.*\.(png|gif|jpg))" "http://${servers:static}/$1" [NC,P,L] +RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L]

So, when an image is requested and the first of these rules is @@ -294,51 +338,6 @@ by many requests.

-
- int: Internal Function - -

When a MapType of int is used, the MapSource is one - of the available internal RewriteMap functions. Module authors can provide - additional internal functions by registering them with the - ap_register_rewrite_mapfunc API. - The functions that are provided by default are: -

- - - -

- To use one of these functions, create a RewriteMap referencing - the int function, and then use that in your RewriteRule: -

- -

Redirect a URI to an all-lowercase version of itself

- - -RewriteMap lc int:tolower -RewriteRule "(.*)" "${lc:$1}" [R] - - - -

Please note that the example offered here is for - illustration purposes only, and is not a recommendation. If you want - to make URLs case-insensitive, consider using - mod_speling instead. -

-
- -
-
prg: External Rewriting Program

When a MapType of prg is used, the MapSource is a @@ -367,10 +366,9 @@ RewriteRule "(.*)" "${lc:$1}" [R]

A simple example is shown here which will replace all dashes with underscores in a request URI.

- +

Rewrite configuration

- RewriteMap d2u "prg:/www/bin/dash2under.pl"
RewriteRule "-" "${d2u:%{REQUEST_URI}}"