If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.
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:
1 2 3 4 5 6 7 8 9 10 11
| NameVirtualHost *
<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost> |
Partager