Hi I'm trying to allow users to domain map to us using CNAME's. Our server is running CentOS 6.4 and Apache. When I create a CNAME on another domain we have with the values:
test.otherdomain.com -> app.example.com
The request loads www.example.com. This is the first rule in my VHOSTS which are ordered as follows;
:80
ServerName www.example.com
ServerAlias example.com
:443
ServerName www.example.com
ServerAlias example.com
:80
ServerName sub1.example.com
:443
ServerName sub1.example.com
:80
ServerName sub2.example.com
:443
ServerName sub2.example.com
:80
ServerName app.example.com
ServerAlias *.example.com
:443
ServerName app.example.com
ServerAlias *.example.com
The *.example.com is to allow users to create custom subdomains, so they can create anything that's not www, sub1, or sub2. Ex: acme.example.com.
After some research I gather the problem is the host being passed doesn't match any of my rules so the first defined site is being served? How can I create a default or catch all site that will serve app.example.com when a user visits test.otherdomain.com?
Users enter their domain in a form on our app so I can't add them all to my vhost entry as aliases. If I put app.example.com as the first rule (without wildcard alias) and again at the bottom of the file with the wildcard alias Apache seems to prefer the wildcard rule and the static subdomains sub1 and sub2 redirect to app.
Thanks!