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

xforms

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1739052 13f79535-47bb-0310-9956-ffa450edef68
parent 85f5ccbe
Loading
Loading
Loading
Loading
+87 −84
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
    <p>This document supplements the <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>
<a href="../mod/mod_rewrite.html">reference documentation</a>. It describes
the use of the <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive,
and provides examples of each of the various <code>RewriteMap</code> types.</p>
and provides examples of each of the various <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> types.</p>

    <div class="warning">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.</div>

  </div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#introduction">Introduction</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#int">int: Internal Function</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#txt">txt: Plain text maps</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#rnd">rnd: Randomized Plain Text</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#dbm">dbm: DBM Hash File</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#int">int: Internal Function</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#prg">prg: External Rewriting Program</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#dbd">dbd or fastdbd: SQL Query</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#summary">Summary</a></li>
@@ -64,8 +64,8 @@ configuration.</div>
   the <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> reference
   documentation.</p>

   <p>The syntax of the <code>RewriteMap</code> directive is as
   follows:</p>
   <p>The syntax of the <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code>
   directive is as follows:</p>

<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
</pre>
@@ -91,12 +91,12 @@ configuration.</div>
      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
      <code class="directive">RewriteMap</code> as:</p>
    <p>For example, you can define a
      <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> as:</p>
    <pre class="prettyprint lang-config">RewriteMap examplemap "txt:/path/to/file/map.txt"</pre>

    <p>You would then be able to use this map in a
      <code class="directive">RewriteRule</code> as follows:</p>
      <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> as follows:</p>
      <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>


@@ -108,41 +108,85 @@ in the map:</p>

<div class="note"><h3>Per-directory and .htaccess context</h3>
<p>
The <code>RewriteMap</code> directive  may not be used in
&lt;Directory&gt; sections or <code>.htaccess</code> files. You must
The <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive may not be
used in <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections or
<code>.htaccess</code> files. You must
declare the map in server or virtualhost context. You may use the map,
once created, in your <code>RewriteRule</code> and
<code>RewriteCond</code> directives in those scopes. You just can't
<strong>declare</strong> it in those scopes.
</p>
once created, in your <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> and
<code class="directive"><a href="../mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> directives in those
scopes. You just can't <strong>declare</strong> it in those scopes.</p>
</div>

<p>The sections that follow describe the various <em>MapType</em>s that
may be used, and give examples of each.</p>
  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="int" id="int">int: Internal Function</a></h2>
    

    <p>When a MapType of <code>int</code> is used, the MapSource is one
    of the available internal <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code>
    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 class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> referencing
    the int function, and then use that in your <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code>:
    </p>

   <p> <strong>Redirect a URI to an all-lowercase version of itself</strong></p>
    <pre class="prettyprint lang-config">RewriteMap lc int:tolower
RewriteRule "(.*)" "${lc:$1}" [R]</pre>


    <div class="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
    <code class="module"><a href="../mod/mod_speling.html">mod_speling</a></code> instead.
    </p>
    </div>

  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="txt" id="txt">txt: Plain text maps</a></h2>
    

    <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">
    <div class="example"><p><code>
      # Comment line<br />
      <strong><em>MatchingKey</em> <em>SubstValue</em></strong><br />
      <strong><em>MatchingKey</em> <em>SubstValue</em></strong> # comment<br />
    </p>
    </code></p></div>

    <p>When the RewriteMap is invoked the argument is looked for in the
    <p>When the <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> 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>
@@ -170,7 +214,8 @@ telephone 328
    </code></p></div>

    <p>Thus, when <code>http://example.com/product/television</code> is
    requested, the <code>RewriteRule</code> is applied, and the request
    requested, the <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> is
    applied, and the request
    is internally mapped to <code>/prods.php?id=993</code>.</p>

    <div class="note"><h3>Note: .htaccess files</h3>
@@ -202,7 +247,7 @@ telephone 328
    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
@@ -224,10 +269,10 @@ RewriteRule "^/(.*)" "http://${servers:dynamic}/$1" [P,L]</pre>


    <p>So, when an image is requested and the first of these rules is
    matched, <code>RewriteMap</code> looks up the string
    matched, <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> looks up the string
    <code>static</code> in the map file, which returns one of the
    specified hostnames at random, which is then used in the
    <code>RewriteRule</code> target.</p>
    <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> target.</p>

    <p>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
 <pre class="prettyprint lang-config">RewriteMap examplemap "dbm=sdbm:/etc/apache/mapfile.dbm"</pre>


    <p>The type can be sdbm, gdbm, ndbm or db.
    <p>The type can be <code>sdbm</code>, <code>gdbm</code>, <code>ndbm</code> 
    or <code>db</code>.
    However, it is recommended that you just use the <a href="../programs/httxt2dbm.html">httxt2dbm</a> 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.</p>
@@ -269,7 +315,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map
</code></p></div>

<p>You can then reference the resulting file in your
<code>RewriteMap</code> directive:</p>
<code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive:</p>

<pre class="prettyprint lang-config">RewriteMap mapname "dbm:/etc/apache/mapfile.map"</pre>

@@ -279,7 +325,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map
a common base name. For example, you may have two files named
<code>mapfile.map.dir</code> and <code>mapfiile.map.pag</code>. This is
normal, and you need only use the base name <code>mapfile.map</code> in
your <code>RewriteMap</code> directive.</p>
your <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive.</p>
</div>

<div class="note"><h3>Cached lookups</h3>
@@ -293,49 +339,6 @@ by many requests.

  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="int" id="int">int: Internal Function</a></h2>
    

    <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>
    <pre class="prettyprint lang-config">RewriteMap lc int:tolower
RewriteRule "(.*)" "${lc:$1}" [R]</pre>


    <div class="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
    <code class="module"><a href="../mod/mod_speling.html">mod_speling</a></code> instead.
    </p>
    </div>

  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="prg" id="prg">prg: External Rewriting Program</a></h2>

    <p>When a MapType of <code>prg</code> is used, the MapSource is a
@@ -426,15 +429,15 @@ the result set is used.</p>
<h2><a name="summary" id="summary">Summary</a></h2>
    

    <p>The <code class="directive">RewriteMap</code> directive can occur more than
    once. For each mapping-function use one
    <code class="directive">RewriteMap</code> directive to declare its rewriting
    mapfile.</p>
    <p>The <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive can
    occur more than once. For each mapping-function use one
    <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive to declare
    its rewriting mapfile.</p>

    <p>While you cannot <strong>declare</strong> a map in
    per-directory context (<code>.htaccess</code> files or
    &lt;Directory&gt; blocks) it is possible to
    <strong>use</strong> this map in per-directory context. </p>
    <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> blocks) it is
    possible to <strong>use</strong> this map in per-directory context.</p>

  </div></div>
<div class="bottomlang">
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.fr.xsl"?>
<!-- English Revision: 1733403 -->
<!-- English Revision: 1733403:1739051 (outdated) -->
<!-- French translation : Lucien GENTIS -->
<!-- Reviewed by : VIncent Deffontaines -->
<!--
+1 −1
Original line number Diff line number Diff line
@@ -8,6 +8,6 @@

  <variants>
    <variant>en</variant>
    <variant>fr</variant>
    <variant outdated="yes">fr</variant>
  </variants>
</metafile>