title: Un obfuscate URL using mod rewrite
body: <p>I work for a company that used to have a polocy of obfuscating URLs for articles which you needed to register to use. So they would have something like</p>
  
  <p>/story.php?story_id=Z_ZXYZ</p>
  
  <p>which there was some code which mapped letters to numbers to work out the true story id</p>
  
  <p>so</p>
  
  <pre><code>Z = 0 
  Y = 1
  X = 2 
  </code></pre>
  
  <p>etc.</p>
  
  <p>We are now moving technology stack and have decided that obfuscated urls are not needed. So I am looking at whether it is possible to un obfuscate the URLs using mod rewrite</p>
  
  <p>So far I have </p>
  
  <pre><code>  RewriteCond %{REQUEST_URI} ^.*story.php [NC]
    RewriteCond %{QUERY_STRING} ^.*story_id=Z_([ZXYWVUTSRQ]*) [NC]
    RewriteRule ^.*$ /story/${decryptmap:%1} [L,R=301]
  </code></pre>
  
  <p>I have a rewrite map in the httpd.conf file</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
    RewriteMap decryptmap txt:decyrpsdstxt
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Which has content</p>
  
  <pre><code>##
  ## decrypt urls
  ##
  Z 0
  X 1
  </code></pre>
  
  <p>etc..</p>
  
  <p>but it dosn't seem to be working, even if I put some text in the Rewriterule as so  <code>RewriteRule ^.*$ /story/${decryptmap:ZXY} [L,R=301]</code> I get a url like <code>/story/?story_id=Z_ZAD</code></p>
  
  <p>Is there anything obvious I am doing wrong? I can see that the two conditions are being matched but the map doesn’t seem to work.</p>
  
  <p>Should I even be trying to get mod rewrite to do this? I could redirect to a script which did this fairly easily but that would put redirect code in two places which I didn't like the idea of.</p>
  
  <p>(I'm not worried about the ?story_id=Z_ZAD, I know how to get rid of that)</p>