BarMeister has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to fix a redirect problem under modperl2. I am using ModPerl::Registry.

The issue is that at the time I want to do the redirect I may or may not have already added some headers and in modperl2 there is no send_http_headers method any more....they just say to set the content_type and that will send out the headers....well what content_type do I use for a redirect?!?

I am obviously doing something really stupid here...but my brain is totally fried so I hope someone can just point me in the right direction.

Thanks :-D

Replies are listed 'Best First'.
Re: modperl2 redirect
by BarMeister (Beadle) on Jul 28, 2008 at 22:23 UTC
    Amazing how right after you spend days trying to figure something out, you ask for help and then figure it out on your own within 5 minutes of asking for that help hehe.

    The solution was to just have:
    print "\n";
    after
    $r->headers_out->add('Location' => $redirect);

    Everything works now....

      While that might work, I don't think it's "right." See the recipes in here: mod_perl: Cooking Recipes. This might be right, untested.

      $r->headers_out->set(Location => $location); $r->status(Apache2::Const::REDIRECT); return Apache2::Const::REDIRECT;