For example, suppose that you are serving the domain www.domain.tld
and you wish to add the virtual host www.otherdomain.tld
, which points at the same IP address. Then you simply add the following to httpd.conf:
You can alternatively specify an explicit IP address in place of the * in both the NameVirtualHost and <VirtualHost> directives. The IP address is required in version 1.3.12 and earlier.
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example if you add this to the first <VirtualHost> block above
ServerAlias domain.tld *.domain.tld
then requests for all hosts in the domain.tld domain will be served by the www.domain.tld
virtual host. The wildcard characters * and ? can be used to match names. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server