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.


  • 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

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

<VirtualHost *>
    ServerName  example.com
    ServerAlias www.example.com
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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