[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rewriting "Location:" in an "ErrorDocument 302" not working. Ideas?


Thanks for the reply, Geoff. 

Matt and I have found what seems to be a reasonable way to accomplish our goal using a Perl Output Filter Handler set up for the specific problem <Location> in Apache.  The following handler rewrites the Location HTTP header as needed:

---

sub handler {
    my ($f) = @_;

    if ($f->ctx) {
        return Apache2::Const::DECLINED;
    }
   
    my $r = $f->r;
    my $loc = $r->headers_out->get('Location');

    if ($loc && $loc =~ /^http:/i) {
        # Change HTTP > HTTPS
        $loc =~ s/^http:/https:/i;
        $r->headers_out->set('Location' => $loc);
    }
    $f->ctx(1);

    return Apache2::Const::DECLINED;
}

---

It completely ignores the bucket brigade but does perform the task of rewriting the Location header in the proxied server's response.  We were surprised to discover it worked even if the filter always returns DECLINED.  We're still open to suggestions if there is a better way.

Thanks,
--Jason

Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.