Hello modperlers,

   I'm currently banging my head on the walls trying to use Perl sections, in
the httpd.conf file, to configure virtual hosts. The idea is to redirect lots
of 'secondary' domains to URLs on our 'main' website.
   Let's say the main website is www.main.org, and secondary domain are
sec.ondary.com and third.dom.com. With a regular Virtual host config, no
sweat (well, it seems so; maybe an Apache expert will tell me I forgot
something big and important :-)

NameVirtualHost 192.168.1.2:80

<VirtualHost 192.168.1.2:80>
        ServerName              sec.ondary.com
        RedirectPermanent /     http://www.main.org/second/index.phtml
</VirtualHost>

<VirtualHost 192.168.1.2:80>
        ServerName              third.dom.com
        RedirectPermanent /     http://www.main.org/third/index.phtml
</VirtualHost>

   Since we have several secondary domains, and lots of URLs to remap in
different ways depending on the secondary domain, I thought going through a
Perl section would be cute. So, dumbly, I wrote this to replace the 
<VirtualHost> sections above (the NameVirtualHost does not change) :

<Perl>
my $realname = 'http://www.main.org';
my %vnames = ( 'sec.ondary.com' => 'second', 'third.dom.com' => 'third' );
foreach (keys %vnames) {
    $VirtualHost{'192.168.1.2:80'} = {
        ServerName => $_,
        RedirectPermanent => ( ['/', "$realname/$vname{$_}/index.phtml"] )
    }
}
</Perl>

   No way. No errors during the server startup, but also no redirection
whatsoever. Where am I wrong, or what did I forget ?
   I'm using
      Embedded Perl version 5.00503 for Apache/1.3.9 (Unix) mod_perl/1.21
      mod_ssl/2.4.9 OpenSSL/0.9.4
   Tia,
-- Pierre-Yves BONNETAIN
   CTO
   http://www.rouge-blanc.com -- Fastest wines in Europe

Reply via email to