On Mon, May 07, 2001 at 09:32:23PM -0400, Philippe M . Chiasson wrote:
> On Mon, May 07, 2001 at 05:35:57PM -0700, Jonathan Hilgeman wrote:
> > I've been trying to do this for some time but can't figure out how.
> > <VirtualHost 111.111.111.111>
> > UseCanonicalName Off
> > <Perl>
> > if($HTTP_HOST =~ s/(?:www\.)?(.*)\.domain\.com//g)
> > {
> > $VirtualDocumentRoot = "/www/httpd/html/$1";
> > }
> > else
> > {
> > $VirtualDocumentRoot = '/www/httpd/html/%-3';
> > }
> > 1;
> > </Perl>
> > </VirtualHost>
> Your problem is that this code is evaluated at startup-time, not request-time.
> So this means it will be run once globally, the regexp won't match and you just
> configure the default. There are many ways to do it.
>
> First, look at mod_vhost_alias http://httpd.apache.org/docs/mod/mod_vhost_alias.html.
> VirtualDocumentRoot /www/httpd/html/%0
>
> Would map requests to www.username.com to /www/httpd/html/www.username.com
> And for the username.com, you could simply use a symlink.
>
> Second, use mod_rewrite http://httpd.apache.org/docs/mod/mod_rewrite.html
> Something like :
>
> RewriteEngine on
> RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.host\.com$
> RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
> RewriteRule ^(www\.)?([^.]+)\.host\.com(.*) /www/httpd/html/$2$3
>
> Third, you could do it in mod_perl with a custom handler
>
> <Perl>
> use Apache::Constants qw(:common);
> sub My::MassVHosting::handler {
> my $r = shift
> if($r->header_in('Host') =~ /^(www\.)?([^.]+)\.domain,com/)
s/,/\\./
> {
> $r->filename("/home/httpd/html/$2");
> $r->stat();
> return OK;
> }
> return Apache::Constants:;DECLINED;
s/;/:/
> }
> </Perl>
> PerlTrancHandler My;;MassVHosting
s/;/:/g
> For more information about mod_per magic, consider getting the book or reading the
>guide
> http://perl.apache.org/guide/
>
> Hope this helps.
>
> P.S. I am not responsible for tyops ;-)
nice disclaimer... :)
--
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html
[EMAIL PROTECTED]
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!