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
/story.php?story_id=Z_ZXYZ
which there was some code which mapped letters to numbers to work out the true story id
so
Z = 0
Y = 1
X = 2
etc.
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
So far I have
RewriteCond %{REQUEST_URI} ^.*story.php [NC]
RewriteCond %{QUERY_STRING} ^.*story_id=Z_([ZXYWVUTSRQ]*) [NC]
RewriteRule ^.*$ /story/${decryptmap:%1} [L,R=301]
I have a rewrite map in the httpd.conf file
<IfModule mod_rewrite.c>
RewriteMap decryptmap txt:decyrpsdstxt
</IfModule>
Which has content
##
## decrypt urls
##
Z 0
X 1
etc..
but it dosn't seem to be working, even if I put some text in the Rewriterule as so RewriteRule ^.*$ /story/${decryptmap:ZXY} [L,R=301]
I get a url like /story/?story_id=Z_ZAD
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.
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.
(I'm not worried about the ?story_id=Z_ZAD, I know how to get rid of that)