My overall goal is to grab a value from a map file using a key (%2). Then compare that value to the initial untainted %{REQUEST_URI}. If they exactly match (see line 3) then no redirect is necessary - just serve it. If they don't match (see line 7), then redirect to the official url is done.
The problem is that line 3 and 7 aren't string comparing like I think they are. Any ideas?
RewriteMap lowercase int:tolower
RewriteMap urls txt:/www/docs/www.domain.com/redirects.url
1. RewriteCond %{REQUEST_URI} ^/([a-z0-9]*)-p-([a-z0-9]+)$
2. RewriteCond ${urls:%2} >""
3. RewriteCond %{REQUEST_URI} ${urls:%2}
4. RewriteRule ^([a-z0-9]*)-p-([a-z0-9]+)$ /realpage.html?%1-%2 [NC,L]
5. RewriteCond %{REQUEST_URI} ^/([a-z0-9]*)-p-([a-z0-9]+)$
6. RewriteCond ${urls:%2} >""
7. RewriteCond %{REQUEST_URI} !${urls:%2}
8. RewriteRule ^([a-z0-9]*)-p-([a-z0-9]+)$ ${urls:%2} [R=301,L]
map file format is:
key1 /test-p-key1
key2 /test-p-key2
key3 /test-p-key3
Example url requests:
/test2-p-key1 (invalid url, will redirect one time)
/test-p-key3 (valid url, no redirects)