I have a three VirtualHosts. The second two utilize wildcards.

  • www.example.com
  • *.sites.example.com (i.e. foo.sites.example.com)
  • *.*.sites.example.com (i.e. foo.bar.sites.example.com)

For the second two, I tried:

ServerName example.com
ServerAlias *.example.com


ServerName example.com
ServerAlias *.*.example.com

Problem is *.example.com gobbles up *.*.example.com. As maybe a hack, I put *.*.example.com before *.example.com in my httpd.conf file.

Is what I did the proper way to do this, or is there a more official way?


You did it the right way. Apache always takes the first VirtualHost if multiple entries match.

For more information about Virtual Host Matching look at the official documentation: http://httpd.apache.org/docs/2.4/vhosts/details.html

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.