I am converting all my current VirtualHost configurations from being declared by ip to being declared by name (w/ NameVirtualHost set).

For this:

<VirtualHost www.test.com>
    ServerAdmin webmaster@test.com
    DocumentRoot /var/www/html/www.test.com/        
    ServerName www.test.com
    ServerAlias test.com
</VirtualHost>

Do I need the ServerAlias or the ServerName? Will it still work without the www?

link|improve this question

38% accept rate
feedback

1 Answer

up vote 1 down vote accepted

You want to set ServerName. ServerAlias just allows you to set aliases for the host.

<VirtualHost www.test.com>
    ServerAdmin webmaster@test.com
    DocumentRoot /var/www/html/www.test.com/        
    ServerName www.test.com
    ServerAlias test.com
</VirtualHost>
link|improve this answer
Just to confirm... "h t t p : //test.com" WILL work without the ServerAlias declaration? – Louis W Dec 29 '09 at 17:10
1  
Whoops, missed it. ServerAlias is required in your case with multiple sites, you will need to configure the DNS A records for both www.test.com and test.com – John T Dec 29 '09 at 17:19
Nope not local... ok I will just leave all the ServerAlais in there. Yes there is multiple sites on this one box. – Louis W Dec 29 '09 at 17:20
When configuring the DNS records make sure both point to the same IP. – John T Dec 29 '09 at 17:21
feedback

Your Answer

 
or
required, but never shown

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