Re: Perl Sections and Virtual Host

2000-04-20 Thread Doug MacEachern

i've only skimmed this thread, but haven't seen any mention of chapter 8
online at http://modperl.com/ which covers  sections in detail.




Re: Perl Sections and Virtual Host

2000-04-19 Thread Pierre-Yves BONNETAIN


> > 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"] )
>   ^^

> Maybe this is just in your example, but you might have cut-and-pasted from
> yor config, so I'll mention it: In your RedirectPermanent, you are referencing
> %vname, not %vnames. Without strict turned on in your  section, Perl 
> won't tell you.

   Yep, I caught this one a few minutes ago (but if I had read my mail earlier,
your message would have saved half of my day. Well, there are times like 
that...).

   I'm getting somewhat closer, I think it's now just a matter of understanding
more precisely 'what' should be used as the RedirectPermanent value. This
work just fine now :


my $realname = 'real.domain.com';

my %vnames = ( 'prim.ary.com' => 'first', 'sec.ondary.com' => 'second' );

$VirtualHost{'192.168.1.2:80'} = [ { ServerName => $realname } ];

foreach (keys %vnames) {
my $vhref = {
ServerName => $_,
RedirectPermanent => "/ http://$realname/$vnames{$_}/"
};

push @{$VirtualHost{'192.168.1.2:80'}}, $vhref;
}


   Whenever I ask for http://prim.ary.com, I get transparently redirected to
http://real.domain.com/first. Cute. Almost there.

   But I have other URLs I want to remap. Say, prim.ary.com/europe should be
mapped to real.domain.com/europe. With the above setup, I am redirected to
real.domain.com/first/europe. So I need now to have _several_ RedirectPermanent
(or anything that could save my whole day -- well, night, it's 23 pm here).
   I have tried a helluva lot of syntaxes, I'm ashamed to say, to no avail. The
right one just escapes me.
   Any hints ?
   Tia,
-- Pierre-Yves BONNETAIN
   CTO -- http://www.rouge-blanc.com  --  Fastest wines in Europe.




Re: Perl Sections and Virtual Host

2000-04-19 Thread darren chamberlain

Pierre-Yves BONNETAIN ([EMAIL PROTECTED]) said something to this effect:
*snip*
> 
> 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"] )
  ^^
> }
> }
> 

Maybe this is just in your example, but you might have cut-and-pasted from
yor config, so I'll mention it: In your RedirectPermanent, you are referencing
%vname, not %vnames. Without strict turned on in your  section, Perl 
won't tell you.

Maybe that's not it, but it's what jumped out at me.

darren

-- 
Never make anything simple and efficient when a way can be found to make it
complex and wonderful.



Perl Sections and Virtual Host

2000-04-18 Thread Pierre-Yves BONNETAIN

   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


ServerName  sec.ondary.com
RedirectPermanent / http://www.main.org/second/index.phtml



ServerName  third.dom.com
RedirectPermanent / http://www.main.org/third/index.phtml


   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 
 sections above (the NameVirtualHost does not change) :


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"] )
}
}


   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