[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache VirtualDocumentRoot



On Wed, May 02, 2001 at 10:27:14PM +0200, Russell Coker took time to write:
> On Wednesday 02 May 2001 20:12, Marcelo Gulin wrote:
> >   I think that mod_rewrite or mod_vhosts_alias can do that.
> >   take a look at http://modules.apache.org
> 
> VirtualDocumentRoot IS mod_vhosts_alias.
> 
> I have read the documentation for mod_rewrite and couldn't work out how to do 
> this.  However mod_rewrite is described as being "like Sendmail" to configure 
> so I may have missed something.  If you know how to do this with mod_rewrite 
> then please explain how to do it!

Here is my try (note : I do not know mod_vhosts_alias, I just
glimpsed over the manual to understand what 
VirtualDocumentRoot /www/%-1/%-2/%-3/%-4+ means)

(helped by § Virtual Hosts on
http://www.engelschall.com/pw/apache/rewriteguide/)

RewriteEngine on
RewriteRule	^(.+)$	%{HTTP_HOST}/$1 
RewriteRule	^([^./]+)\.([^./]+)/(.*)			/www/$2/$1/$3		[L,PT]
RewriteRule	^([^./]+)\.([^./]+)\.([^./]+)/(.*)	 	/www/$3/$2/$1/$4	[L,PT]
RewriteRule	^([^/]+)\.([^./]+)\.([^./]+)\.([^./]+)/(.*)	/www/$4/$3/$2/$1/$5	[L,PT]

This must be tested (and will work only for HTTP/1.1 requests), and can surely be improved.
I am not sure about the PT flag, especially for request without a filename at the end.

I hope that helps, let us know !

-- 
Patrick.
``C'est un monde qui n'a pas les moyens de ne plus avoir mal.''

Attachment: pgp_96f2mPF58.pgp
Description: PGP signature


Reply to: