Dynamic Virtual Hosts In Apache with www and non-www subdomains

Posted by haukish on Server Fault See other posts from Server Fault or by haukish
Published on 2012-12-15T19:44:26Z Indexed on 2012/12/15 23:06 UTC
Read the original article Hit count: 172

Filed under:
|

I don't know apache very well and I've got a problem with configure mod_vhost_alias

This is my httpd.conf file:

UseCanonicalName Off

LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon

<Directory /var/www/sites/>
Options FollowSymLinks
AllowOverride All
</Directory>

<VirtualHost *:80>
    CustomLog logs/access_log.sites vcommon
    ServerAlias *.domain.com
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/sites/%1/
</VirtualHost>

Subdomains work fine without www. but I need to make them work with www too.

Here's an example:

something.domain.com - site is loading
www.something.domain.com - Not Found

What should I do?

© Server Fault or respective owner

Related posts about apache2

Related posts about mod-vhost-alias