I am trying the following
RewriteMap lookup "txt:D:/lookup.txt"
RewriteCond %{REQUEST_URI} ^/${lookup}
RewriteRule ^/(.*)/(.*)$ /a/$1/b/$2.html [PT,L]
I am trying to compare if the request path is starting with the valid paths or not.
I have a long list of paths in the lookup file.
Please help on this.
I've discovered that you cannot have a variable in the
RewriteCond
regex, because it seems it is only compiled once, but not per-request.You could workaround this by putting both
${lookup}
and%{REQUEST_URI}
in a test string using a separator (let's say a comma) and then make sure they are equal, e.g :Also note that, for this given sample URL
http://mydomain.dom/abc/mypage.html
:but
So
%{REQUEST_URI}
will never be equal to${lookup:$1}
.To make them equal when requested, you have to :
${lookup:$1}
with/
to get/abc/
=/${lookup:$1}/
$2
to also get the requested file :/abc/mypage.html
=/${lookup:$1}/$2
/abc/
(and notabc
) you need to enclode$1
with/
to match the key :/${lookup:/$1/}/
So finally you will have this :
Going to
http://mydomain.dom/abc/mypage.html
gives me the following log :