Apache + Perl + PHP3 + MySQL Windows 9x


MySQL - 9


header. Old HTTP/1.0 clients do not send such a header and Apache has no clue what vhost the client tried to reach (and serves the request from the primary vhost). To provide as much backward compatibility as possible we create a primary vhost which returns a single page containing links with an URL prefix to the name-based virtual hosts.

Server configuration:

...

NameVirtualHost 111.22.33.44

 

<VirtualHost 111.22.33.44>

# primary vhost

DocumentRoot /www/subdomain

RewriteEngine On

RewriteRule ^/.* /www/subdomain/index.html

...

</VirtualHost>

 

<VirtualHost 111.22.33.44>

DocumentRoot /www/subdomain/sub1

ServerName www.sub1.domain.tld

ServerPath /sub1/

RewriteEngine On

RewriteRule ^(/sub1/.*) /www/subdomain$1

...

</VirtualHost>

 

<VirtualHost 111.22.33.44>

DocumentRoot /www/subdomain/sub2

ServerName www.sub2.domain.tld

ServerPath /sub2/

RewriteEngine On

RewriteRule ^(/sub2/.*) /www/subdomain$1

...

</VirtualHost>

Due to the ServerPath directive a request to the URL http://www.sub1.domain.tld/sub1/

is always

served from the sub1-vhost.

A request to the URL http://www.sub1.domain.tld/

is only served from the sub1-vhost if the client sent a correct Host: header. If no Host:

header is sent the client gets the information page from the primary host.

Please note that there is one oddity: A request to http://www.sub2.domain.tld/sub1/

is also served from the sub1-vhost if the client sent no Host:

header.

The RewriteRule

directives are used to make sure that a client which sent a correct Host: header can use both URL variants, i.e., with or without URL prefix.

 




- -  - -