Way to write vhost for same subdomain across multiple domains?
-
03-07-2019 - |
Question
I've got several domains setup in /etc/apache2/sites-enabled:
domain1.com
domain2.com
domain3.com
I need to setup webmail.domain*.com for each one. I can do this with individual vhost files for each, but is there a way to write a wildcard vhost to be caught by all domains?
Also, the same directory should be served by all webmail.*.com requests.
Solution
ServerAlias allows wildcards
OTHER TIPS
Despite my mean~ness, check out Apache's vhosts documentation looks like the answer is not. You need a FQDN, not a globbing character.
Ah, here's what worked for me:
<VirtualHost *:80>
ServerName webmail.domain.com
ServerAlias webmail.*
DocumentRoot /path/to/webmail
UseCanonicalName Off
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow