]> granicus.if.org Git - apache/blobdiff - docs/manual/rewrite/rewritemap.html.en
Link to canonical hostnames recipe from "avoid" document.
[apache] / docs / manual / rewrite / rewritemap.html.en
index d5cb00404a4a1c7e768578b7ed7c67f4ce148c60..64f78d33f66dbb625a16dfb926d3a5a52142254c 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
+<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
+<!--
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
               This file is generated from xml source: DO NOT EDIT
         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@@ -64,7 +66,8 @@ configuration.</div>
    <p>The syntax of the <code>RewriteMap</code> directive is as
    follows:</p>
 
-<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></pre>
+<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em>
+</pre>
 
 
     <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an
@@ -89,17 +92,17 @@ configuration.</div>
 
     <p>For example, you can define a
       <code class="directive">RewriteMap</code> as:</p>
-    <pre class="prettyprint lang-config">RewriteMap examplemap txt:/path/to/file/map.txt</pre>
+    <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>
-<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1}</pre>
+      <pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1}"</pre>
 
 
 <p>A default value can be specified in the event that nothing is found
 in the map:</p>
 
-<pre class="prettyprint lang-config">RewriteRule ^/ex/(.*) ${examplemap:$1|/not_found.html}</pre>
+<pre class="prettyprint lang-config">RewriteRule "^/ex/(.*)" "${examplemap:$1|/not_found.html}"</pre>
 
 
 <div class="note"><h3>Per-directory and .htaccess context</h3>
@@ -146,8 +149,8 @@ may be used, and give examples of each.</p>
     </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 (.*?[A-Z]+.*) ${lc:$1} [R]</pre>
+    <pre class="prettyprint lang-config">RewriteMap lc "int:tolower"
+RewriteRule "(.*?[A-Z]+.*)" "${lc:$1}" [R]</pre>
 
 
     <div class="note">
@@ -184,8 +187,8 @@ RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]</pre>
     product IDs for easier-to-remember URLs, using the following
     recipe:</p>
 <p><strong>Product to ID configuration</strong></p>
-    <pre class="prettyprint lang-config">RewriteMap product2id txt:/etc/apache2/productmap.txt
-RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
+    <pre class="prettyprint lang-config">RewriteMap product2id "txt:/etc/apache2/productmap.txt"
+RewriteRule "^/product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]</pre>
 
 
     <p>We assume here that the <code>prods.php</code> script knows what
@@ -216,7 +219,7 @@ telephone  328
     scope. If you're planning to use this in a <code>.htaccess</code>
     file, you'll need to remove the leading slash from the rewrite
     pattern in order for it to match anything:
-    <pre class="prettyprint lang-config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
+    <pre class="prettyprint lang-config">RewriteRule "^product/(.*)" "/prods.php?id=${product2id:$1|NOTFOUND}" [PT]</pre>
 
     </div>
 
@@ -255,10 +258,10 @@ static   www1|www2|www3|www4<br />
 dynamic  www5|www6
     </code></p></div>
 <p><strong>Configuration directives</strong></p>
-    <pre class="prettyprint lang-config">RewriteMap servers rnd:/path/to/file/map.txt
+    <pre class="prettyprint lang-config">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]</pre>
+RewriteRule "^/(.*\.(png|gif|jpg))" "http://${servers:static}/$1"  [NC,P,L]
+RewriteRule "^/(.*)"                "http://${servers:dynamic}/$1" [P,L]</pre>
 
 
     <p>So, when an image is requested and the first of these rules is
@@ -290,7 +293,7 @@ static   www1|www1|www2|www3|www4
 
     <p>You may optionally specify a particular dbm type:</p>
 
- <pre class="prettyprint lang-config">RewriteMap examplemap dbm=sdbm:/etc/apache/mapfile.dbm</pre>
+ <pre class="prettyprint lang-config">RewriteMap examplemap "dbm=sdbm:/etc/apache/mapfile.dbm"</pre>
 
 
     <p>The type can be sdbm, gdbm, ndbm or db.
@@ -309,7 +312,7 @@ $ httxt2dbm -i mapfile.txt -o mapfile.map
 <p>You can then reference the resulting file in your
 <code>RewriteMap</code> directive:</p>
 
-<pre class="prettyprint lang-config">RewriteMap mapname dbm:/etc/apache/mapfile.map</pre>
+<pre class="prettyprint lang-config">RewriteMap mapname "dbm:/etc/apache/mapfile.map"</pre>
 
 
 <div class="note">
@@ -351,6 +354,12 @@ by many requests.
     a context that does not have <code class="directive"><a href="../mod/mod_rewrite.html#rewriteengine">RewriteEngine</a></code> set to
     <code>on</code>.</p>
 
+    <p>By default, external rewriting programs are run as the
+    user:group who started httpd. This can be changed on UNIX systems
+    by passing user name and group name as third argument to
+    <code class="directive"><a href="../mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> in the
+    <code>username:groupname</code> format.</p>
+
     <p>This feature utilizes the <code>rewrite-map</code> mutex,
     which is required for reliable communication with the program.
     The mutex mechanism and lock file can be configured with the
@@ -358,10 +367,10 @@ by many requests.
 
     <p>A simple example is shown here which will replace all dashes with
     underscores in a request URI.</p>
-    
+
 <p><strong>Rewrite configuration</strong></p>
-    <pre class="prettyprint lang-config">RewriteMap d2u prg:/www/bin/dash2under.pl<br />
-RewriteRule - ${d2u:%{REQUEST_URI}}</pre>
+    <pre class="prettyprint lang-config">RewriteMap d2u "prg:/www/bin/dash2under.programlisting" apache:apache<br />
+RewriteRule "-" "${d2u:%{REQUEST_URI}}"</pre>
 
 
     <p><strong>dash2under.pl</strong></p>
@@ -452,7 +461,7 @@ var comments_identifier = 'http://httpd.apache.org/docs/trunk/rewrite/rewritemap
     }
 })(window, document);
 //--><!]]></script></div><div id="footer">
-<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
+<p class="apache">Copyright 2015 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
 if (typeof(prettyPrint) !== 'undefined') {
     prettyPrint();