From b5cf9d9ee1b68490c55d6ad968528b315a8ab12d Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Thu, 14 Apr 2016 10:50:46 +0000 Subject: [PATCH] xforms git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1739049 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/rewrite/rewritemap.html.en | 70 ++++++++++++++------------ 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/docs/manual/rewrite/rewritemap.html.en b/docs/manual/rewrite/rewritemap.html.en index 2e5a05be68..726293223f 100644 --- a/docs/manual/rewrite/rewritemap.html.en +++ b/docs/manual/rewrite/rewritemap.html.en @@ -30,7 +30,7 @@

This document supplements the mod_rewrite reference documentation. It describes the use of the RewriteMap directive, -and provides examples of each of the various RewriteMap types.

+and provides examples of each of the various RewriteMap types.

Note that many of these examples won't work unchanged in your particular server configuration, so it's important that you understand @@ -63,8 +63,8 @@ configuration.
the RewriteMap reference documentation.

-

The syntax of the RewriteMap directive is as - follows:

+

The syntax of the RewriteMap + directive is as follows:

RewriteMap MapName MapType:MapSource
 
@@ -91,11 +91,11 @@ configuration. if no DefaultValue was specified.

For example, you can define a - RewriteMap as:

+ 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 as follows:

RewriteRule "^/ex/(.*)" "${examplemap:$1}"
@@ -107,13 +107,13 @@ in the map:

Per-directory and .htaccess context

-The RewriteMap directive may not be used in -<Directory> sections or .htaccess files. You must +The RewriteMap directive may not be +used in <Directory> sections or +.htaccess files. You must declare the map in server or virtualhost context. You may use the map, -once created, in your RewriteRule and -RewriteCond directives in those scopes. You just can't -declare it in those scopes. -

+once created, in your RewriteRule and +RewriteCond directives in those +scopes. You just can't declare it in those scopes.

The sections that follow describe the various MapTypes that @@ -124,7 +124,8 @@ may be used, and give examples of each.

When a MapType of int is used, the MapSource is one - of the available internal RewriteMap functions. Module authors can provide + 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: @@ -144,13 +145,13 @@ may be used, and give examples of each.

- To use one of these functions, create a RewriteMap referencing - the int function, and then use that in your RewriteRule: + 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]
+RewriteRule "(.*)" "${lc:$1}" [R]
@@ -167,8 +168,8 @@ RewriteRule (.*) ${lc:$1} [R]

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.

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

@@ -179,7 +180,8 @@ RewriteRule (.*) ${lc:$1} [R] MatchingKey SubstValue # comment

-

When the RewriteMap is invoked the argument is looked for in the +

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.

@@ -211,7 +213,8 @@ telephone 328

Thus, when http://example.com/product/television is - requested, the RewriteRule is applied, and the request + requested, the RewriteRule is + applied, and the request is internally mapped to /prods.php?id=993.

Note: .htaccess files

@@ -265,10 +268,10 @@ RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L]

So, when an image is requested and the first of these rules is - matched, RewriteMap looks up the string + matched, RewriteMap looks up the string static in the map file, which returns one of the specified hostnames at random, which is then used in the - RewriteRule target.

+ RewriteRule target.

If you wanted to have one of the servers more likely to be chosen (for example, if one of the server has more memory than the others, @@ -296,7 +299,8 @@ static www1|www1|www2|www3|www4

RewriteMap examplemap "dbm=sdbm:/etc/apache/mapfile.dbm"
-

The type can be sdbm, gdbm, ndbm or db. +

The type can be sdbm, gdbm, ndbm + or db. However, it is recommended that you just use the httxt2dbm utility that is provided with Apache HTTP Server, as it will use the correct DBM library, matching the one that was used when httpd itself was built.

@@ -310,7 +314,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map

You can then reference the resulting file in your -RewriteMap directive:

+RewriteMap directive:

RewriteMap mapname "dbm:/etc/apache/mapfile.map"
@@ -320,7 +324,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map a common base name. For example, you may have two files named mapfile.map.dir and mapfiile.map.pag. This is normal, and you need only use the base name mapfile.map in -your RewriteMap directive.

+your RewriteMap directive.

Cached lookups

@@ -368,7 +372,7 @@ by many requests.

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

-

Rewrite configuration

+

Rewrite configuration

RewriteMap d2u "prg:/www/bin/dash2under.programlisting" apache:apache
RewriteRule "-" "${d2u:%{REQUEST_URI}}"
@@ -420,9 +424,9 @@ this process, or if the script itself is very slow. restarted.

If a query returns more than one row, a random row from -the result set is used.

+ the result set is used.

-

Example

RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
+

Example

RewriteMap myquery "fastdbd:SELECT destination FROM rewrite WHERE source = %s"
top
@@ -430,15 +434,15 @@ the result set is used.

Summary

-

The RewriteMap directive can occur more than - once. For each mapping-function use one - RewriteMap directive to declare its rewriting - mapfile.

+

The RewriteMap directive can + occur more than once. For each mapping-function use one + RewriteMap directive to declare + its rewriting mapfile.

While you cannot declare a map in per-directory context (.htaccess files or - <Directory> blocks) it is possible to - use this map in per-directory context.

+ <Directory> blocks) it is + possible to use this map in per-directory context.

-- 2.50.1