December 04, 2002

internal_redirect in CGI

Journal of merlyn (47)

Recently, there's been a discussion on PerlMonks about how an internal redirect wasn't working. I traced it down to a few lines of mod_cgi.c in the Apache source code. For an internal redirect, a location header must be present, begin with a slash (no hostname) and the status must be 200.
Unfortunately, the standard redirect routine defaults the status to be 302. Thus, you have to remember to write the redirect as

print redirect(-uri => '/new/location', -status => 200);


CGIでも Location: と Status: 200 で internal redirect になるって話。だいぶ昔にきいて、そうはならないなーと思って放置してたのですが、status が問題なのですね。

Posted by miyagawa at December 4, 2002 03:22 AM | Permalink | Comments (0) | TrackBack(0)
TrackBack URL for this entry:
Post a comment