You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Carl Johnstone <mo...@fadetoblack.me.uk> on 2006/03/17 17:41:54 UTC
[mp1] redirect in ErrorDocument
In an Apache::Registry ErrorDocument (e.g. ErrorDocument 404 /my404.pl )
This doesn't work:
$r->header_out('Location', $newurl);
$r->status(302);
return OK;
Apache returns an error saying that my 404 handler returned a 302 error.
Does the same if I use err_header_out
Yet enabling "PerlSendHeader On" and doing:
print "Location: $newurl\n\n";
works fine.
I'd prefer to get the first way working - any ideas?
Carl
Re: [mp1] redirect in ErrorDocument
Posted by Carl Johnstone <mo...@fadetoblack.demon.co.uk>.
> > Yet enabling "PerlSendHeader On" and doing:
> >
> > print "Location: $newurl\n\n";
> >
> > works fine.
>
> What are the complete headers that sends? I'm guessing it sends a 200
> status and it only works because your browser is broken and follows the
> redirect anyway.
No, it does convert the Location header into a 302 response, although it
doesn't add the body content like returning a 302 in the main request does.
>>>>>
HTTP/1.1 302 Found
Date: Mon, 20 Mar 2006 13:31:55 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_gzip/1.3.26.1a PHP/4.3.10-16
mod_perl/1.29
Set-Cookie: Apache=127.0.0.1.155421142861522485; path=/; expires=Sat,
16-Sep-06 13:31:55 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Location: http://www.manchesteronline.co.uk/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain; charset=utf-8
0
Connection closed by foreign host.
<<<<<
Carl
Re: [mp1] redirect in ErrorDocument
Posted by Perrin Harkins <pe...@elem.com>.
On Fri, 2006-03-17 at 16:41 +0000, Carl Johnstone wrote:
> In an Apache::Registry ErrorDocument (e.g. ErrorDocument 404 /my404.pl )
>
> This doesn't work:
>
> $r->header_out('Location', $newurl);
> $r->status(302);
> return OK;
>
>
> Apache returns an error saying that my 404 handler returned a 302 error.
I'm not sure apache will let you do this.
> Does the same if I use err_header_out
>
> Yet enabling "PerlSendHeader On" and doing:
>
> print "Location: $newurl\n\n";
>
> works fine.
What are the complete headers that sends? I'm guessing it sends a 200
status and it only works because your browser is broken and follows the
redirect anyway.
- Perrin
Re: [mp1] redirect in ErrorDocument
Posted by Tom Schindl <to...@gmx.at>.
Not sure but give err_headers_out a try?
Tom
Carl Johnstone wrote:
>
> In an Apache::Registry ErrorDocument (e.g. ErrorDocument 404 /my404.pl )
>
> This doesn't work:
>
> $r->header_out('Location', $newurl);
> $r->status(302);
> return OK;
>
>
> Apache returns an error saying that my 404 handler returned a 302 error.
> Does the same if I use err_header_out
>
> Yet enabling "PerlSendHeader On" and doing:
>
> print "Location: $newurl\n\n";
>
> works fine.
>
>
> I'd prefer to get the first way working - any ideas?
>
> Carl
>
>