RewriteCond %{HTTP_HOST} ^([^.]+)\.nanosouffle\.net$ RewriteCond %{REQUEST_URI} !^(.*)\.pl$ RewriteRule ^/(.*)$ /usr/local/www/nanosouffle/%1/data/$1 [L] RewriteCond %{REQUEST_URI} ^(.*)\.pl$ RewriteRule ^/(.*)$ /nanosouffle/%2/data/$1 [PT] ... AliasMatch ^/nanosouffle/(.*)\.pl$ /home/www/perl/$1 # It is apparent that %2 (of HTTP_HOST backreference) is not being substituted in the RewriteRule here -- any ideas?