Recently I decided to give AWS a try to see how it perform. I created an EC2 container. I installed linux and apache. I tried to configure apache so that i could host more than one domain. There I had the th trouble.
These are the directives i added to apache configuration.
<VirtualHost *:80>
ServerName domain1.com
DocumentRoot /var/www/vhosts/domain1.com/httpdocs
<Directory /var/www/vhosts/domain1.com/httpdocs>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.com
DocumentRoot /var/www/vhosts/domain2.com/httpdocs
<Directory /var/www/vhosts/domain2.com/httpdocs>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domain3.com
DocumentRoot /var/www/vhosts/domain3.com/httpdocs
<Directory /var/www/vhosts/domain3.com/httpdocs>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domain4.com
DocumentRoot /var/www/vhosts/domain4.com/httpdocs
<Directory /var/www/vhosts/domain4.com/httpdocs>
AllowOverride All
</Directory>
</VirtualHost>
I set up the dns configuration so domain1.com domain2.com domain3.com and domain4.com
are A records pointing to the ip number of the container.
Then I set up dns configuration so www.domain1.com is a cname pointing to domain1.com, www.domain2.com is a cname pointing to domain2.com, www.domain3.com is a cname pointing to domain3.com, www.domain4.com is a cname pointing to domain4.com
When I visit the domains, there is no problem. http://domain1.com/ http://domain2.com/ http://domain3.com/ and http://domain4.com/
works excellent. They point to the corresponding directories.
However, I have a big problem with the cnames. http://www.domain1.com/ http://www.domain2.com/ http://www.domain3.com/ and http://www.domain4.com/
do not point to the corresponding domains but all of them show me what i should see at http://domain1.com/
Any assistance is highly appreciated.