I am trying to implement some dynamic virtual hosting using mod_rewrite. I have been having a few problems though. With my implementation, I use an external rewriting script that I wrote in Perl. It accepts a domain name and returns the path. Here is my rewrite config in my httpd.conf:
RewriteEngine On
RewriteMap low int:tolower
RewriteMap vhost prg:/usr/bin/rewrite
RewriteCond ${low:%{HTTP_HOST}} (.+)$
RewriteCond ${vhost:%1} (.+)$
RewriteRule /(.*)$ %1/$1
The problem is that the back reference in the last RewriteCond isn't being set. If I replace the back reference, "%1" with "domain.com" the rewrite is successful and returns the path associated with domain.com. The HTTP_HOST var is being set, I tested it. Am I doing something wrong?