httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Haase-Thomas <...@meome-ag.de>
Subject Re: Subdomains with mod_rewrite
Date Mon, 04 Mar 2002 09:13:02 GMT
Sorry, the last rule has to be
RewriteRule .* $1/$3$2
...
well, maybe...

Martin Haase-Thomas wrote:

> Hi,
>
> maybe this is what you're looking for. I didn't test it at all, but i 
> think it should work. Perhaps it will lead apache into a endless loop. 
> If it does, append something like "RewriteRule (.*) $1 [L]"
>
> RewriteCond .* (.*)(dom.ain)
> RewriteRule .* $2/$1 [C]
> RewriteCond (.*) (dom.ain)([a-zA-Z0-9_-]*)\.(.*)
> RewriteRule .* $1/$2$3 [N]
>
> Regards
> Martin
>
>
>
>
>
>
> Alexander Skwar wrote:
>
>> 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
>>
>

-- 
                   http://www.meome.de
-------------------------------------------------------
Martin Haase-Thomas         |       Tel.: 030 43730-558
meOme AG                    |       Fax.: 030 43730-555
Software Development        |           mht@meome-ag.de
-------------------------------------------------------




---------------------------------------------------------------------
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