From: Daniel Gruno
For example, we might use a mapfile to translate product names to product IDs for easier-to-remember URLs, using the following recipe:
- -#Product to ID configuration +Product to ID configuration
+RewriteMap product2id txt:/etc/apache2/productmap.txt RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]@@ -214,8 +214,8 @@ telephone 328 static www1|www2|www3|www4
dynamic www5|www6 - -#Configuration directives +Configuration directives
+RewriteMap servers rnd:/path/to/file/map.txt RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L] @@ -325,7 +325,9 @@ by many requests. the int function, and then use that in yourRewriteRule
: -#Redirect a URI to an all-lowercase version of itself +Redirect a URI to an all-lowercase version of itself
++ RewriteMap lc int:tolower RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]@@ -369,7 +371,7 @@ RewriteRule (.*?[A-Z]+.*) ${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
diff --git a/docs/manual/rewrite/rewritemap.xml b/docs/manual/rewrite/rewritemap.xml index 6bd721d45e..79010f8026 100644 --- a/docs/manual/rewrite/rewritemap.xml +++ b/docs/manual/rewrite/rewritemap.xml @@ -133,8 +133,8 @@ may be used, and give examples of each.For example, we might use a mapfile to translate product names to product IDs for easier-to-remember URLs, using the following recipe:
- -#Product to ID configuration + Product to ID configuration
+RewriteMap product2id txt:/etc/apache2/productmap.txt RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT] @@ -203,8 +203,8 @@ telephone 328 static www1|www2|www3|www4
dynamic www5|www6 - -#Configuration directives + Configuration directives
+RewriteMap servers rnd:/path/to/file/map.txt RewriteRule ^/(.*\.(png|gif|jpg)) http://${servers:static}/$1 [NC,P,L] @@ -312,7 +312,9 @@ by many requests. the int function, and then use that in your RewriteRule
: -#Redirect a URI to an all-lowercase version of itself + Redirect a URI to an all-lowercase version of itself
++ RewriteMap lc int:tolower RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R] @@ -356,7 +358,7 @@ RewriteRule (.*?[A-Z]+.*) ${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