1

I am trying to configure my Apache instance to support a catch-all sort of construct for domains.

I want the root domain, ie: example.com and all *.example.com to be directed to one specific DocumentRoot. However I have one caveat, I have existing sub domains. ie: sub1.example.com sub2.example.com as well as sub1.something.example.com that have different a different respective DocumentRoot (except in the case of the ones starting with sub1. (for example))

What is a sane way to configure this? Is it even possible?

chris
  • 167
  • 1
  • 9

1 Answers1

1

Apache will search for the hostname provided in the Host: header from first defined vhost to last defined vhost. The first vhost that matches is used. If there is no match then the first defined vhost is used as the default vhost.

You should define your existing vhosts before you define the catchall for example.com. Your last defined vhost should be your default. Remember that ServerName cannot contain wildcards whilst ServerAlias can.

user9517
  • 115,471
  • 20
  • 215
  • 297