Example Virtual Host Apache Configuration
by Stephen Fluin 2010.07.14Someone asked for an example of Apache Virtual Hosts configuration. All of my virtual hosts have the same format as the following two examples:
Types of Virtual Host Configurations
Name Based Virtual Hosts
There are two main types of virtual host configuration. The first called "Name Based" virtual hosting matches the examples above. In this case, the domain name provided as part of the request determines the site that apache matches. Name based hosting does not work with SSL because Apache doesn't know the domain name requested until AFTER the encryption negotiation is complete.
Address Based Virtual Hosts
The second type of virtual host is address based hosting. This will only be used when the server has many IPs. The server uses the interface (server ip or port) of the incoming request to determine the site to respond with. This is almost always used to establish SSL hosting in combination with name based hosting.
Example address based virtual hosts:
Dynamic Virtual Hosts
The third type (which is new to me) is mass or dynamically configured hosts. These hosts use the IP or Domain name to determine the DocumentRoot of the site. Read the Apache spec here. Example of what would go in your httpd.conf below:
The %0 when used with VirtualDocumentRoot replaces %0 with the domain name.
permalink