Commit d0acf80c authored by Christophe Jaillet's avatar Christophe Jaillet
Browse files

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
parent a7614363
Loading
Loading
Loading
Loading
+59 −61
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
      substituted by <em>DefaultValue</em> or by the empty string
      if no <em>DefaultValue</em> was specified.</p>

    <p>For example, you might define a
    <p>For example, you can define a
      <directive>RewriteMap</directive> as:</p>
    <highlight language="config">
RewriteMap examplemap "txt:/path/to/file/map.txt"
@@ -117,28 +117,72 @@ once created, in your <code>RewriteRule</code> and
may be used, and give examples of each.</p>
  </section>

  <section id="int">
    <title>int: Internal Function</title>

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

    <ul>
      <li><strong>toupper</strong>:<br/>
             Converts the key to all upper case.</li>
      <li><strong>tolower</strong>:<br/>
             Converts the key to all lower case.</li>
      <li><strong>escape</strong>:<br/>
             Translates special characters in the key to
            hex-encodings.</li>
      <li><strong>unescape</strong>:<br/>
             Translates hex-encodings in the key back to
            special characters.</li>
    </ul>

    <p>
    To use one of these functions, create a <code>RewriteMap</code> referencing
    the int function, and then use that in your <code>RewriteRule</code>:
    </p>

   <p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
    <highlight language="config">

RewriteMap lc int:tolower
RewriteRule "(.*)" "${lc:$1}" [R]
    </highlight>

    <note>
    <p>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
    <module>mod_speling</module> instead.
    </p>
    </note>

  </section>

  <section id="txt">
    <title>txt: Plain text maps</title>

    <p>When a MapType of <code>txt</code> 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.</p>

    <p>For example, the following might be valid entries in a map
    file.</p>
    <p>A valid text rewrite map file will have the following syntax:</p>

    <p class="indent">
    <example>
      # Comment line<br />
      <strong><em>MatchingKey</em> <em>SubstValue</em></strong><br />
      <strong><em>MatchingKey</em> <em>SubstValue</em></strong> # comment<br />
    </p>
    </example>

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

    <p>For example, we might use a mapfile to translate product names to
    <p>For example, we can use a mapfile to translate product names to
    product IDs for easier-to-remember URLs, using the following
    recipe:</p>
<p><strong>Product to ID configuration</strong></p>
@@ -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.</p>

    <p>For example, you might use the following map
    <p>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
@@ -294,51 +338,6 @@ by many requests.

  </section>

  <section id="int">
    <title>int: Internal Function</title>

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

    <ul>
      <li><strong>toupper</strong>:<br/>
             Converts the key to all upper case.</li>
      <li><strong>tolower</strong>:<br/>
             Converts the key to all lower case.</li>
      <li><strong>escape</strong>:<br/>
             Translates special characters in the key to
            hex-encodings.</li>
      <li><strong>unescape</strong>:<br/>
             Translates hex-encodings in the key back to
            special characters.</li>
    </ul>

    <p>
    To use one of these functions, create a <code>RewriteMap</code> referencing
    the int function, and then use that in your <code>RewriteRule</code>:
    </p>

   <p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
    <highlight language="config">

RewriteMap lc int:tolower
RewriteRule "(.*)" "${lc:$1}" [R]
    </highlight>

    <note>
    <p>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
    <module>mod_speling</module> instead.
    </p>
    </note>

  </section>

  <section id="prg"><title>prg: External Rewriting Program</title>

    <p>When a MapType of <code>prg</code> is used, the MapSource is a
@@ -370,7 +369,6 @@ RewriteRule "(.*)" "${lc:$1}" [R]

<p><strong>Rewrite configuration</strong></p>
    <highlight language="config">

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