Wednesday, August 17, 2016

apache 2.2 - Multiple VirtualHosts files for subdomains in apache2



I'm new with apache2 and virtualHosts and all these things, I'm trying to set multiple subdomains, each in one file.



For example, I'll have



quentin-dommerc.com file in site-available :





DocumentRoot /var/www/
ServerName quentin-dommerc.com



and en.quentin-dommerc.com file in site-available :




DocumentRoot /var/www/en/

ServerName en.quentin-dommerc.com



But whatever the subdomain I go to, I'm always on quentin-dommerc.com :(



Note that I've a2ensite my files and they're well in site-enabled. I've also reloaded/restarted apache2. My CNAME are also set.


Answer



Try changing your VirtualHost entries to use your ip address instead of domain name. e.g. if you ip address is 1.1.1.1





DocumentRoot /var/www/
ServerName quentin-dommerc.com



DocumentRoot /var/www/en/
ServerName en.quentin-dommerc.com




You may also have to update your Listen lines to reflect using the ip address.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...