|
Apache HTTP Server Version 1.3Apache name-based Virtual Host SupportSee Also: IP-based Virtual Host SupportName-based vs. IP-based virtual hostsWhile the approach with IP-based virtual hosts works very well,
it is not the most elegant solution, because a dedicated IP address
is needed for every virtual host and it is hard to implement on some
machines. The The benefits of using the new name-based virtual host support is a practically unlimited number of servers, ease of configuration and use, and requires no additional hardware or software. The main disadvantage is that the client must support this part of the protocol. The latest versions of most browsers do, but there are still old browsers in use who do not. This can cause problems, although a possible solution is addressed below. Using non-IP Virtual HostsUsing the new virtual hosts is quite easy, and superficially looks
like the old method. You simply add to one of the Apache configuration
files (most likely NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> ServerName www.domain.tld DocumentRoot /web/domain </VirtualHost> The notable difference between IP-based and name-based virtual host
configuration is the
Of course, any additional directives can (and should) be placed
into the Note: When you specify an IP address in a Additionally, many servers may wish to be accessible by more than
one name. For example, the example server might want to be accessible
as ServerAlias domain.tld *.domain.tld Note that you can use You also might need Compatibility with Older BrowsersAs mentioned earlier, there are still some clients in use who do not send the required data for the name-based virtual hosts to work properly. These clients will always be sent the pages from the primary name-based virtual host (the first virtual host appearing in the configuration file for a specific IP address). There is a possible workaround with the
Example configuration: NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> ServerName www.domain.tld ServerPath /domain DocumentRoot /web/domain </VirtualHost> What does this mean? It means that a request for any URI beginning
with "/domain" will be served from the virtual host
www.domain.tld This means that the pages can be accessed as
In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/ Then, in the virtual host's pages, be sure to use either purely relative links (e.g. "file.html" or "../icons/image.gif" or links containing the prefacing /domain/ (e.g. "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html"). This requires a bit of discipline, but adherence to these guidelines will, for the most part, ensure that your pages will work with all browsers, new and old. See also: ServerPath configuration example Apache HTTP Server Version 1.3 |
|||||||||||||||||
With any suggestions or questions please feel free to contact us |