Apache2: Trying to map a subdomain to a subdirectory
Posted
by
user1561753
on Server Fault
See other posts from Server Fault
or by user1561753
Published on 2013-10-24T18:57:15Z
Indexed on
2013/10/24
21:57 UTC
Read the original article
Hit count: 371
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
© Server Fault or respective owner