Recipe 4.3 Setting Up Address-Based Virtual Hosts


You have multiple IP addresses assigned to your system, and you want to support one web site on each.


Create a virtual host section for each IP address you want to list on:

ServerName <VirtualHost>     ServerName     DocumentRoot "C:/Apache/Sites/TheSmiths" </VirtualHost> <VirtualHost>     ServerName     DocumentRoot "C:/Apache/Sites/JustJohnSmith" </VirtualHost>


The virtual hosts defined in this example catch all requests to the specified IP addresses, regardless of what hostname is used to get there. Requests to any other IP address not listed go to the virtual host listed in the main body of the configuration file.

The ServerName specified is used as the primary name of the virtual host, when needed, but is not used in the process of mapping a request to the correct host. Only the IP address is consulted to figure out which virtual host to serve requests from, not the Host header field.

See Also


Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: