Apache + Perl + PHP3 + MySQL Windows 9x


MySQL - 7


DocumentRoot /www/otherdomain2

ServerName www.otherdomain2.tld

...

</VirtualHost>

Port-based vhosts

         Setup: The server machine has one IP address (111.22.33.44) which resolves to the name www.domain.tld. If we don't have the option to get another address or alias for our server we can use port-based vhosts if we need a virtual host with a different configuration.

Server configuration:

...

Listen 80

Listen 8080

ServerName www.domain.tld

DocumentRoot /www/domain

 

<VirtualHost 111.22.33.44:8080>

DocumentRoot /www/domain2

...

</VirtualHost>

A request to www.domain.tld

on port 80 is served from the main server and a request to port 8080 is served from the virtual host.

Using _default_ vhosts

         Setup 1: Catching every request to any unspecified IP address and port, i.e., an address/port combination that is not used for any other virtual host.

Server configuration:

...

<VirtualHost _default_:*>

DocumentRoot /www/default

...

</VirtualHost>

Using such a default vhost with a wildcard port effectively prevents any request going to the main server.

A default vhost never serves a request that was sent to an address/port that is used for name-based vhosts. If the request contained an unknown or no Host: header it is always served from the primary name-based vhost (the vhost for that address/port appearing first in the configuration file).

You can use AliasMatch or RewriteRule to rewrite any request to a single information page (or script).

         Setup 2: Same as setup 1, but the server listens on several ports and we want to use a second _default_ vhost for port 80.

Server configuration:

...

<VirtualHost _default_:80>

DocumentRoot /www/default80

...

</VirtualHost>




- -  - -  - -