Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 :

<VirtualHost quentin-dommerc.com:80>
              DocumentRoot /var/www/
              ServerName quentin-dommerc.com
</VirtualHost>

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

<VirtualHost en.quentin-dommerc.com:80>
              DocumentRoot /var/www/en/
              ServerName en.quentin-dommerc.com
</VirtualHost>

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.

share|improve this question
    
are the contents of the two folders /var/www/en and /var/www different? does the domain name itself change? if so, is there a redirect in /var/www/en/ that send the user to quentin-dommerc.com? –  drone.ah Feb 10 '13 at 12:55
    
Yes they're differents. Nope, it is juste a subdomain of the root domain quentin-dommerc.com. –  Kentino Feb 10 '13 at 13:07
    
what does the domain name say when you go to the subdomain? does it redirect to the root domain? –  drone.ah Feb 10 '13 at 13:22
    
Yep exactly, it redirects me to the root domain ! –  Kentino Feb 10 '13 at 13:37
    
is this live? I just visited the subdomain and while it displayed the same content as the root domain, it did not redirect... –  drone.ah Feb 10 '13 at 14:14
add comment

1 Answer

up vote 2 down vote accepted

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

<VirtualHost 1.1.1.1:80>
          DocumentRoot /var/www/
          ServerName quentin-dommerc.com
</VirtualHost>

<VirtualHost 1.1.1.1:80>
          DocumentRoot /var/www/en/
          ServerName en.quentin-dommerc.com
</VirtualHost>

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.