Mixing Name-based and IP-based Virtual Hosts


It is possible to mix and match IP-based and name-based virtual hosts, as shown in Listing 5.4. Instead of using NameVirtualHost *, you will need to provide separate NameVirtualHost directives for each IP address that will be associated with name-based virtual hosts. This example shows two name-based virtual hosts associated with the 192.168.200.2 IP address and one IP-based virtual host associated with IP address 192.168.200.4.

Listing 5.4. Mixing IP-based and Name-based Virtual Hosting

NameVirtualHost 192.168.200.2 <VirtualHost 192.168.200.2>     ServerName www.example.com     DocumentRoot /usr/local/apache/sites/example.com </VirtualHost> <VirtualHost 192.168.200.2>     ServerName staging.example.com     DocumentRoot /usr/local/apache/sites/staging </VirtualHost> <VirtualHost 192.168.200.4>     ServerName www.example.net     DocumentRoot /usr/local/apache/sites/example.net </VirtualHost>




Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net