Apache2: Trying to map a subdomain to a subdirectory
- by user1561753
So basically I want to have:
sub.domain.com/anything - domain.com/asub/anything
I'm a bit new to this and a bit confused. The first thing I did was configure my DNS settings so sub.domain.com goes to domain.com using a CNAME (would an A record and the IP be better?)
Next I went into my VirtualHost file and have:
RewriteEngine on
RewriteCond %{HTTP_HOST} www.(.+) [NC]
RewriteRule ^/(.*) http://domain.com/$1 [R]
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^/(.*) http://domain.com/asub/$1 [R]
So the first rule is meant to handle www. and making sure that is caught correctly and it works.
The second rule is what I've added for the subdomain mapping and it doesn't seem to be doing anything