From fdf5241c95e96790171c7b7d6e3f823458be1108 Mon Sep 17 00:00:00 2001 From: Daniel Gruno Date: Fri, 11 May 2012 10:23:12 +0000 Subject: [PATCH] Added a portion about using the %-2.0.%-1.0 combination for managing virtual document roots. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1337101 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_vhost_alias.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/manual/mod/mod_vhost_alias.xml b/docs/manual/mod/mod_vhost_alias.xml index 6c27b9685a..b1d716b443 100644 --- a/docs/manual/mod/mod_vhost_alias.xml +++ b/docs/manual/mod/mod_vhost_alias.xml @@ -171,6 +171,25 @@ VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2

The example request would come from /usr/local/apache/vhosts/example.com/d/o/m/ain/directory/file.html.

+

A very common request by users is the ability to point multiple domains to multiple +document roots without having to worry about the length or number of parts of the +hostname being requested. If the requested hostname is sub.www.domain.example.com + instead of simply www.domain.example.com, then using %3+ will result in the document +root being /usr/local/apache/vhosts/domain.example.com/... instead of the +intended example.com directory. In such cases, it can be beneficial to use +the combination %-2.0.%-1.0, which will always yield the domain name and the +tld, for example example.com regardless of the number of subdomains appended +to the hostname. As such, one can make a configuration that will direct all first, second +or third level subdomains to the same directory: +

+ + VirtualDocumentRoot "/usr/local/apache/vhosts/%-2.0.%-1.0" + +

+In the example above, both www.example.com as well as www.sub.example.com +or example.com will all point to /usr/local/apache/vhosts/example.com. +

+

For IP-based virtual hosting you might use the following in your configuration file:

-- 2.40.0