in reply to VHosting large number of domains(50+), mod-perl

What's wrong with ServerAlias, possibly combined with a RewriteRule?

For example:

<VirtualHost 1.2.3.4> DocumentRoot /path/to/a/single/directory ServerName www.mainserver.name ServerAlias www.foo.com ServerAlias www.bar.com # etc. etc. about 50 times # all ServerAliases could be a on a single line, # but I prefer seperate lines for readability # only do the following if you want only the main URL to appear in the + URL-bar RewriteEngine On RewriteCond %{HTTP_HOST} !^www.mainserver.name$ [ +NC] RewriteRule ^.*$ http://www.mainserver.name/ [ +R,L] # other stuff you need for these domains </VirtualHost>

Liz

Replies are listed 'Best First'.
Re: Re: VHosting large number of domains(50+), mod-perl
by BUU (Prior) on Oct 05, 2003 at 17:35 UTC
    Ah, liz, I have no idea how I missed ServerAlias in the apache docs, but that looks perfect for my needs.
Re: Re: VHosting large number of domains(50+), mod-perl
by Juerd (Abbot) on Oct 06, 2003 at 18:33 UTC

    It is better to put the alternative hosts in their own <VirtualHost> block if you are going to use mod_rewrite with them. Otherwise, you get the performance hit of mod_rewrite with every hit on the "real" site.

    <VirtualHost 123.123.123.123> ServerName foo.com ServerAlias www.foo.com ... </VirtualHost> <VirtualHost 123.123.123.123> ServerName other.foo.com ServerAlias bar.com ServerAlias www.bar.com ServerAlias quux.com ServerAlias www.quux.com ... RewriteEngine on # RewriteCond not necessary anymore RewriteRule ... </VirtualHost>

    That said, I must say that I hate typing in all those domains and prefer wildcards, when possible :)

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Hrm.. virtualhost wild cards? Can you elaborate please?