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'd like to setup my virtual host to not require WWW. I want it to be subdomain agnostic. How can this be accomplished? Thanks!

Edit: sorry I was not clear. I host multiple sites on the same apache install, each with its own virtual host. I want each one to be accessible with and without www, ie: www-agnostic.

so www.google.com and google.com are both caught by the same vhost.

Thanks!

share|improve this question
    
you probably don't need virtual hosts for this if you don't have subdomains. Just set the Listen 80/Listen 443 at the top of the httpd.conf. –  Jason Huntley Mar 28 '12 at 19:28
    
Yeah, if you only want your website not to require www. then just don't type it. –  gparent Mar 28 '12 at 19:30
    
Did you get this working? I saw you wrote a comment about how it didn't work, but looks like you edited or deleted it afterwards. –  gparent Mar 28 '12 at 20:40
add comment

1 Answer 1

This should do the trick assuming your DNS records are set straight:

<VirtualHost *>
    ServerName  example.com
    ServerAlias www.example.com
    ....
</VirtualHost>
share|improve this answer
    
Edited original post. –  coergoa Mar 28 '12 at 19:37
1  
It's the same answer, but I'll edit it. Simply add virtualhosts as needed. –  gparent Mar 28 '12 at 19:41
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.