in reply to Redirection using a mod_perl handler (PerlPostReadRequestHandler ?)

If it needs to be done "very very early" I tend to use PerlInitHandler which translates to either PostReadRequestHandler if in the configuration files, or PerlHeaderParserHandler if in a post-trans location, like an .htaccess file. Both of those are as soon as possible in that phase.

However, if you already have a PerlTransHandler, you can just drop this code into it:

use Apache::Constants qw(REDIRECT); # if you don't already have it sub handler { my $r = shift; # normal {grin} ... if (detect your cookie here) { $r->header_out(Location => "http://web.stonehenge.com/perltraining +/"); return REDIRECT; } ... }
I don't play much with cookies, so I don't have any examples of detecting the cookie, but I presume you do. {grin} Oh yeah, and change that sample URL unless you want them to Learn some more Perl from some Experts. {grin} </code>

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Redirection using a mod_perl handler (PerlPostReadRequestHandler ?)
  • Download Code