Recipe 4.11 Port-Based Virtual Hosts


You want to present different content for HTTP connections on different ports.


Explicitly list the port number in the <VirtualHost> declaration:

    Listen 8080     <VirtualHost>         DocumentRoot /www/vhosts/port8080     </VirtualHost>     Listen 9090     <VirtualHost>         DocumentRoot /www/vhosts/port9090     <VirtualHost>


Port-based virtual hosting is somewhat less common than other techniques shown in this chapter. However, there are a variety of situations in which it can be useful. If you have only one IP address, have no ability to add hostnames to DNS, or if your ISP blocks in-bound traffic on port 80, it may be useful to run virtual hosts on other ports.

Visitors to your web site must list the port number in the URL that they use. For example, to load content from the second virtual host previously listed, the following URL might be used:

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: