Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C8BE0191C1 for ; Thu, 14 Apr 2016 11:02:37 +0000 (UTC) Received: (qmail 35078 invoked by uid 500); 14 Apr 2016 11:02:37 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 35015 invoked by uid 500); 14 Apr 2016 11:02:37 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 35006 invoked by uid 99); 14 Apr 2016 11:02:37 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Apr 2016 11:02:37 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 3D0E4180184 for ; Thu, 14 Apr 2016 11:02:37 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.799 X-Spam-Level: * X-Spam-Status: No, score=1.799 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id wTs9OzBTmCrw for ; Thu, 14 Apr 2016 11:02:33 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTP id 72BC25F20E for ; Thu, 14 Apr 2016 11:02:32 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 3C366E0054 for ; Thu, 14 Apr 2016 11:02:31 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 38A6E3A0315 for ; Thu, 14 Apr 2016 11:02:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1739052 - in /httpd/httpd/branches/2.4.x/docs/manual/rewrite: rewritemap.html.en rewritemap.xml.fr rewritemap.xml.meta Date: Thu, 14 Apr 2016 11:02:31 -0000 To: cvs@httpd.apache.org From: jailletc36@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160414110231.38A6E3A0315@svn01-us-west.apache.org> Author: jailletc36 Date: Thu Apr 14 11:02:31 2016 New Revision: 1739052 URL: http://svn.apache.org/viewvc?rev=1739052&view=rev Log: xforms Modified: httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.html.en httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.fr httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.meta Modified: httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.html.en URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.html.en?rev=1739052&r1=1739051&r2=1739052&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.html.en (original) +++ httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.html.en Thu Apr 14 11:02:31 2016 @@ -31,7 +31,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 @@ -40,10 +40,10 @@ 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,13 +91,13 @@ configuration. substituted by DefaultValue or by the empty string if no DefaultValue was specified.

-

For example, you might define a - RewriteMap as:

+

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

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

A default value can be specified in the event that nothing is found @@ -108,41 +108,85 @@ 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 may be used, and give examples of each.

top
+

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

+ +
    +
  • toupper:
    + Converts the key to all upper case.
  • +
  • tolower:
    + Converts the key to all lower case.
  • +
  • escape:
    + Translates special characters in the key to + hex-encodings.
  • +
  • unescape:
    + Translates hex-encodings in the key back to + special characters.
  • +
+ +

+ 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. +

+
+ +
top
+

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 +

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

@@ -170,7 +214,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

@@ -202,7 +247,7 @@ telephone 328 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 @@ -219,15 +264,15 @@ dynamic www5|www6

Configuration directives

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 - 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, @@ -255,7 +300,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.

@@ -269,7 +315,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.ma

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

+RewriteMap directive:

RewriteMap mapname "dbm:/etc/apache/mapfile.map"
@@ -279,7 +325,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.ma 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

@@ -293,49 +339,6 @@ by many requests.
top
-

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: -

- -
    -
  • toupper:
    - Converts the key to all upper case.
  • -
  • tolower:
    - Converts the key to all lower case.
  • -
  • escape:
    - Translates special characters in the key to - hex-encodings.
  • -
  • unescape:
    - Translates hex-encodings in the key back to - special characters.
  • -
- -

- 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. -

-
- -
top
-

prg: External Rewriting Program

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

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.pl"
RewriteRule "-" "${d2u:%{REQUEST_URI}}"
@@ -416,9 +419,9 @@ this process, or if the script itself is 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
@@ -426,15 +429,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.

Modified: httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.fr URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.fr?rev=1739052&r1=1739051&r2=1739052&view=diff ============================================================================== --- httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.fr (original) +++ httpd/httpd/branches/2.4.x/docs/manual/rewrite/rewritemap.xml.fr Thu Apr 14 11:02:31 2016 @@ -1,7 +1,7 @@ - +