perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <>
Subject Re: 302 redirects from scripts.
Date Wed, 03 Jan 2007 16:24:21 GMT
Ian Grant wrote:
> Dear mod_perl types,
> A system I have installed relies on doing redirects like the code below, but 
> the redirects don't happen, I just get blank pages in the browser.
> I have tested temp redirects in httpd.conf and they work fine.
> Can anyone tell me if the code below should work, or is there something I need 
> to call to get the Location header output?
> use strict;
> use Apache2::RequestUtil ();
> my $request=Apache2::RequestUtil->request();
> my $url='';
> $request->status_line("302 Moved");

don't alter the status line directly.  instead use


from Registry scripts.  once you move to proper mod_perl handlers,
simply calling

  return Apache2::Const::REDIRECT;

is sufficient - no call to $request->status() required.

> $request->headers_out->{'Location'} = $url;
> print STDERR "redir: redirecting to $url\n";
> exit;

better form to

  return Apache2::Const::REDIRECT;

than to call exit - since mod_perl processes never really exit this call
ends up being overridden anyway.  just fyi :)



View raw message