0

I'd like to redirect all subdomains *.local to their sub dirs, for example:

test.local/ --> /files/test/data/

Here's my vhost file:

<VirtualHost *:80>
    ServerName local
    ServerAlias *.local
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.* [NC]
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.local
    RewriteCond /files/%1/data -d
    RewriteRule ^(.*) /mv/$1/data
</VirtualHost>

The trouble is that's not working, I get a file not found error.

Any ideas?

1 Answer 1

0

While you've got more going on there in the mod_rewrite setup than just this, VirtualDocumentRoot may fill your needs?

<VirtualHost *:80>
    ServerName local
    ServerAlias *.local
    VirtualDocumentRoot /files/%-2/data
</VirtualHost>

(the %-2 specifies that the second to last name in the domain should be used; so for www.test.local and for test.local, /files/test/data will be used in both cases)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .