rewritemap.html.en revision 3cfb051391f3d6aa28a25ca3feb81e841242f9d5
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak This file is generated from xml source: DO NOT EDIT
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<title>Using RewriteMap - Apache HTTP Server</title>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<script src="/style/scripts/prettify.js" type="text/javascript">
27e52281f1522522b170cafc76b08b58aa70ccaand<link href="/images/favicon.ico" rel="shortcut icon" /></head>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.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>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<p class="apache">Apache HTTP Server Version 2.5</p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Rewrite</a></div><div id="page-content"><div id="preamble"><h1>Using RewriteMap</h1>
fa8cb8bed4a53a272c6a0de218bcf36390ca5c2bjsl<p><span>Available Languages: </span><a href="/en/rewrite/rewritemap.html" title="English"> en </a></p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <p>This document supplements the <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<a href="/mod/mod_rewrite.html">reference documentation</a>. It describes
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniakthe use of the <code class="directive"><a href="/mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive,
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniakand provides examples of each of the various <code>RewriteMap</code> types.</p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <div class="warning">Note that many of these examples won't work unchanged in your
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniakparticular server configuration, so it's important that you understand
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniakthem, rather than merely cutting and pasting the examples into your
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniakconfiguration.</div>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#introduction">Introduction</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#txt">txt: Plain text maps</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#rnd">rnd: Randomized Plain Text</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#dbm">dbm: DBM Hash File</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#int">int: Internal Function</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#prg">prg: External Rewriting Program</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#dbd">dbd or fastdbd: SQL Query</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<li><img alt="" src="/images/down.gif" /> <a href="#summary">Summary</a></li>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak</ul><h3>See also</h3><ul class="seealso"><li><a href="/mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li><li><a href="remapping.html">Redirection and remapping</a></li><li><a href="access.html">Controlling access</a></li><li><a href="vhosts.html">Virtual hosts</a></li><li><a href="proxy.html">Proxying</a></li><li><a href="advanced.html">Advanced techniques</a></li><li><a href="avoid.html">When not to use mod_rewrite</a></li></ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<h2><a name="introduction" id="introduction">Introduction</a></h2>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak The <code class="directive"><a href="/mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> directive
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak defines an external function which can be called in the context of
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> or
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code class="directive"><a href="/mod/mod_rewrite.html#rewritecond">RewriteCond</a></code> directives to
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak perform rewriting that is too complicated, or too specialized to be
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak performed just by regular expressions. The source of this lookup can
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak be any of the types listed in the sections below, and enumerated in
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak the <code class="directive"><a href="/mod/mod_rewrite.html#rewritemap">RewriteMap</a></code> reference
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak documentation.</p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <p>The syntax of the <code>RewriteMap</code> directive is as
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak follows:</p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak<pre class="prettyprint lang-config">RewriteMap <em>MapName</em> <em>MapType</em>:<em>MapSource</em></pre>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <p>The <a id="mapfunc" name="mapfunc"><em>MapName</em></a> is an
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak arbitray name that you assign to the map, and which you will use in
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak directives later on. Arguments are passed to the map via the
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak following syntax:</p>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code>${</code> <em>MapName</em> <code>:</code> <em>LookupKey</em>
5652dbe450e4fcfdf36d4cfb42d7f2345ded29a4maczniak <code>}</code> <br /> <code>${</code> <em>MapName</em> <code>:</code>
RewriteRule ^/product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]
<pre class="prettyprint lang-config">RewriteRule ^product/(.*) /prods.php?id=${product2id:$1|NOTFOUND} [PT]</pre>
However, it is recommended that you just use the <a href="/programs/httxt2dbm.html">httxt2dbm</a> utility that is
a context that does not have <code class="directive"><a href="/mod/mod_rewrite.html#rewriteengine">RewriteEngine</a></code> set to
<p><code class="module"><a href="/mod/mod_dbd.html">mod_dbd</a></code> will need to be configured to point at
<p><span>Available Languages: </span><a href="/en/rewrite/rewritemap.html" title="English"> en </a></p>
</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div id="disqus_thread" /><script type="text/javascript">
var disqus_identifier = window.location.href.replace(/(current|trunk)/, "2.4").replace(/\/[a-z]{2}\//, "/") + '.' + lang;
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
<p class="apache">Copyright 2012 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/directives.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[//><!--