apache map single subdomain to folder

Viewed 21921

In my /var/www I have a number of sites (goodsite, badsite, uglysite). Right now they are accessed by mydomain.com/goodsite, etc..

What I want is for one site in particuar, uglysite, to be accessed by uglysite.mydomain.com - the others remain as they are.

I have tried all sorts of ways of fiddling with the.htaccess (in /var/www). Note I have mod-rewrite enabled and mod vhost-alias enabled.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^uglysite\.mydomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/uglysite/
RewriteRule ^(.*)$ /uglysite/$1 [L]

What ends up happening is that both mydomain.com and uglysite.mydomain.com always map to the same thing (i.e., the index at /var/www). I tried adding in a new virtual host, and was surprised to find that uglysite.mydomain.com mapped correctly, but then mydomain.com also mapped directly to uglysite as well.

<Virtualhost uglysite.mydomain.com:80>
       ServerName uglysite.mydomain.com
       ServerAdmin www@localhost
       DocumentRoot "/var/www/"
       AccessFileName .htaccess
       <Directory "/var/www/uglysite">
               Order allow,deny
               Allow from All
               AllowOverride All
       </Directory>
</VirtualHost>

The above was added to my sites-enabled/000-default file. This got uglysite.mydomain.com to work properly, but then mydomain.com mapped to the same thing!

Is there a straightforward way to do what I'm intending to do?? Thanks in advance.

1 Answers
Related