Rob Hudson <[EMAIL PROTECTED]> writes:

 % This one.  By different web services, you mean different document roots,
 % I assume.

 % > Or are you asking

 % >     Is there a way to set up DNS such that 
 % >        *.example.com is directed
 % >        to a single host and
 % >        on that host all of the
 % >        host.example.com
 % >        are directed to different web services?       


 This is possible to do.

 a) DNS is able to use wild cards.

  You can use a * as the name of the *.example.com
  in DNS. And this will point all those hosts to that IP

http://www.menandmice.com/online_docs_and_faq/glossary/glossarytoc.htm?wildcard.htm


 b) You want to have multiple hosts definitions. If you look at
    the apache documentation, you will find a good explanation

http://httpd.apache.org/docs/vhosts/mass.html

        
   bascially this example will do what you want:

Simple dynamic virtual hosts using mod_rewrite

This extract from httpd.conf does the same thing as the first example. The first half 
is very similar to the corresponding part above but with some changes for backward 
compatibility and to make the mod_rewrite part work properly; the second half 
configures mod_rewrite to do the actual work.

There are a couple of especially tricky bits: By default, mod_rewrite runs before the 
other URI translation modules (mod_alias etc.) so if they are used then mod_rewrite 
must be configured to accommodate them. Also, mome magic must be performed to do a 
per-dynamic-virtual-host equivalent of ScriptAlias.

# get the server name from the Host: header
UseCanonicalName Off

# splittable logs
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon

<Directory /www/hosts>
    # ExecCGI is needed here because we can't force
    # CGI execution in the way that ScriptAlias does
    Options FollowSymLinks ExecCGI
</Directory>

# now for the hard bit

RewriteEngine On

# a ServerName derived from a Host: header may be any case at all
RewriteMap  lowercase  int:tolower

## deal with normal documents first:
# allow Alias /icons/ to work - repeat for other aliases
RewriteCond  %{REQUEST_URI}  !^/icons/
# allow CGIs to work
RewriteCond  %{REQUEST_URI}  !^/cgi-bin/
# do the magic
RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/docs/$1

## and now deal with CGIs - we have to force a MIME type
RewriteCond  %{REQUEST_URI}  ^/cgi-bin/
RewriteRule  ^/(.*)$  /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1  
[T=application/x-httpd-cgi]

 
 



-----
John Sechrest          .         Helping people use
                        .           computers and the Internet
                          .            more effectively
                             .                      
                                 .       Internet: [EMAIL PROTECTED]
                                      .   
                                              . http://www.peak.org/~sechrest
_______________________________________________
EUGLUG mailing list
[EMAIL PROTECTED]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to