httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Skwar <ASk...@DigitalProjects.com>
Subject Subdomains with mod_rewrite
Date Sun, 03 Mar 2002 09:29:42 GMT
Hello all!

I'd like to setup my Apache 1.3.23 so, that it translates subdomain
requests to directories automagically.  Let me give you some examples
(the domain name is dom.ain):

Request                                 Redirect
a) http://dom.ain                       No redirect
b) http://sub.dom.ain                   http://dom.ain/sub
c) http://foo.sub.dom.ain               http://dom.ain/sub/foo
d) http://bar.foo.sub.dom.ain           http://dom.ain/sub/foo/bar
e) http://blah.bar.foo.sub.dom.ain      http://dom.ain/sub/foo/bar/blah

This means, that if one subdomain is requested, Apache should look for
the files in a folder with the same name as the subdomain (case a)
*sub*.dom.ain -> dom.ain/*sub*).

If two or more subdomains are requested, for the lookup it should
reverse the order of the domainnames and change the '.' to '/' to get
directory delimiters (cases c) to e)).

However, if the HTTP_HOST starts with www., the www. should be ignored
for all the translations.

For the most simple case a) I've got the following rules:

RewriteCond     %{HTTP_HOST}    ^[^.]+\.dom\.ain$
RewriteRule     ^(.+)   %{HTTP_HOST}$1  [C]
RewriteRule     ^([^.]+)\.dom.ain(.*)   /var/www/html/$1/$2

Well, could somebody please help me with the cases c) to e)?

Thanks a lot,

Alexander Skwar
-- 
How to quote:	http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:	http://www.iso-top.de      |     Jabber: askwar@charente.de
   iso-top.de - Die g√ľnstige Art an Linux Distributionen zu kommen
                       Uptime: 1 day 0 hours 39 minutes

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message