You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marc Slemko <ma...@worldgate.com> on 1997/11/19 00:48:23 UTC

virtual domains using mod_rewrite

Has anyone done any work on trying to make something like the below work
completely?  This would be very cool to be able to do fully.  Then you can
implement a hostname for each user without using virtualhosts.  Hey, you
can even use only one IP.  marcs.wild.znep.com == alive.znep.com/~marcs,
ann.wild.znep.com == alive.znep.com/~ann, etc.  Only one A record needed
for all of them.  No mess, no changes required when you add users.

Problems with the example given include that .htaccess files aren't being
read properly, logs aren't always as expected, redirects (eg. directory
requests without a trailing '/') don't give the correct hostname. 

Some are probably fixable without code changes.  Others may be more
difficult.

Anyone else think this is really cool?

Oh, Ralph, I think a lot of mod_rewrite docs from www.engelschall.com
would be very useful included in mod_rewrite docs in the distribution.  

>From http://www.engelschall.com/sw/mod_rewrite/docs/mod_rewrite/solutions.html:

   Virtual User Hosts                                                      
   Problem Description:                                                
   Assume that you want to provide www.username.host.domain.com for the  
   homepage of username via just DNS A records to the same machine and  
   without any virtualhosts on this machine.                             
   Problem Solution:                                                     
   For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests
   which contain a Host: HTTP header we can use the following ruleset to
   rewrite http://www.username.host.com/anypath internally to            
   /home/username/anypath:                                             
RewriteEngine on                                                        
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.host\.com$      
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C] 
RewriteRule   ^www\.([^.]+)\.host\.com(.*) /home/$1$2                    



Re: virtual domains using mod_rewrite

Posted by Marc Slemko <ma...@worldgate.com>.
Cool, they are using the wildcard A record thing too.

I just think this is such a cool thing.  I don't care about doing it,
since I don't have enough users to really care, but I just love how
conceptually clean it is and how it shows off the power of Apache +
mod_rewrite.

I'm sure I could trade them a hack to Apache to allocate shared data in
shared memory instead of using copy on write for info on how they are
doing it.  <g>

On Tue, 18 Nov 1997, Manoj Kasichainula wrote:

> On Tue, Nov 18, 1997 at 04:48:23PM -0700, Marc Slemko wrote:
> > Has anyone done any work on trying to make something like the below work
> > completely?  This would be very cool to be able to do fully.  Then you can
> > implement a hostname for each user without using virtualhosts.  Hey, you
> > can even use only one IP.  marcs.wild.znep.com == alive.znep.com/~marcs,
> > ann.wild.znep.com == alive.znep.com/~ann, etc.  Only one A record needed
> > for all of them.  No mess, no changes required when you add users.
> 
> If y'all are friendly with the MindSpring folks, ask them. They're
> running Apache 1.2.1 and they provide this feature.
> username.home.mindspring.com is a cname for www.mindspring.com. When
> it's requested, the server sends back www.mindspring.com/~username/.
> It's cool enough to make me consider moving my web stuff there.
> 
> -- 
> Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
> "Lawyers are the first refuge of the incompetent." - Aaron Allston
> 


Re: virtual domains using mod_rewrite

Posted by Manoj Kasichainula <ma...@io.com>.
On Tue, Nov 18, 1997 at 04:48:23PM -0700, Marc Slemko wrote:
> Has anyone done any work on trying to make something like the below work
> completely?  This would be very cool to be able to do fully.  Then you can
> implement a hostname for each user without using virtualhosts.  Hey, you
> can even use only one IP.  marcs.wild.znep.com == alive.znep.com/~marcs,
> ann.wild.znep.com == alive.znep.com/~ann, etc.  Only one A record needed
> for all of them.  No mess, no changes required when you add users.

If y'all are friendly with the MindSpring folks, ask them. They're
running Apache 1.2.1 and they provide this feature.
username.home.mindspring.com is a cname for www.mindspring.com. When
it's requested, the server sends back www.mindspring.com/~username/.
It's cool enough to make me consider moving my web stuff there.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
"Lawyers are the first refuge of the incompetent." - Aaron Allston