I can't figure out why the below doesn't work
RewriteCond ${foobar:test:$1} ^
RewriteRule ^/?(.*)$ /check.php?url=$1 [L]
foobar
is a program (simple bash script) and from within it I am writing to file to see what the input is. check.php
is a simple php script which displays the contents of GET
. Here is what I get when I pass the regular expression ($1
) to both the shell script and the php script:
url check.php foobar
www.example.com/index.html index.html test:
www.example.com/index.php index.php test:
www.example.com/test.html test.html test:
basically, the pattern is recognized within the RewriteRule, but not the parameter to foobar.
Note: there is nothing wrong with the shell script. If instead I call it like so ${foobar:test:abc123}
the output is "test:abc123
"
From my point of view:
RewriteCond ${foobar:test:$1} ^
the first $1
is a non-sense because $1
should refer to a previous expression, like:
RewriteRule ^/?(.*)$ /check.php?url=$1 [L]
So I don't get how this could work, and if something works, it's... strange.
See http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap
Maybe something like:
RewriteRule ^(.*)$ ${foobar:test:$1} [R,L,NC]
Could work.