I have a server with multiple websites in subfolders that I want to give their own domains. I'm got two subdomains setup using VirtualHost as such:
<VirtualHost *:80> DocumentRoot "/var/www/ex1" ServerName ex1.domain.com </VirtualHost> <VirtualHost *:80> DocumentRoot "/var/www/ex2" ServerName ex2.domain.com </VirtualHost>
They are setup as A records in my DNS, and they work fine when accessing ex1.domain.com and ex2.domain.com, and the main domain www.domain.com works as well.
However, when I setup their main domains, www.example1.com as CNAME record redirecting to ex1.domain.com, visting www.example1.com shows me www.domain.com and not ex1.domain.com as it should.
What am I doing wrong?