Can multiple domains be ServerAlias'ed to one directory?

I have several domain names and they’re all variable spellings of my main domain but I want them all to display the same website. Can I do this with ServerAlias? Or must I set up a VirtualHost for each name?

If it can be done with ServerAlias, is this the correct way and will it work with and without the www?


<VirtualHost *>
    DocumentRoot /Sites/example
    ServerName www.example.com
    ServerAlias *.example.com example.com
    ServerAlias *.x-ample.com example.com
    ServerAlias *.xmpl.com example.com
    ServerAlias *.egzample.com example.com
</VirtualHost>

I am sure you have probably tried it by now but the above can be done as :-


<VirtualHost *>
    DocumentRoot /Sites/example
    ServerName www.example.com
    ServerAlias *.example.com *.x-ample.com *.xmpl.com *.egzample.com
</VirtualHost>

HTH

Gav…

…there is no spoon.

Dorian, what you have suggested is the way to go. Don’t forget to set up wildcard A records on the DNS for those domain names!

Gav, I understand the point you are making - but just wish to point out that the ServerAlias directive you have given is missing the domain name without any subdomain; that is,

example.com
x-ample.com
xmpl.com
egzample.com

So those would need to be added into the ServerAlias directive you give.