Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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>
share|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

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.