Entry
Is there a simple cgi module for Python that can do redirect?
Feb 21st, 2002 06:01
Kai Surendorf, unknown unknown, Jarkko Torppa, Teemu Keskinarkaus, Apache FAQ, Fredrik Lundh
Using:
print "Status: 302 Moved"
print "Location: http://url.to.somewhere"
Results in:
'Premature end of script headers' errors in apache error_log whenever
the script is used. However, the browser is redirected to url.
Solution:
There might be a module somewhere, but it is so simple that it is not
necessary.
Headerterminator (empty line) and body is missing from your cgi
script, add something like. Dunno if the body is necessary.
print
print '<html><head><title>302 go away</title></head>'
print '<body><p>go away</p></body>'
Documentation:
Here's what the apache FAQ has to say about this message:
http://www.apache.org/docs/misc/FAQ.html#premature-script-headers
"What does it mean when my CGIs fail with "Premature
end of script headers"?
"It means just what it says: the server was expecting a complete
set of HTTP headers (one or more followed by a blank line), and
didn't get them."
Another Solution might be:
Print "Location: http://www.your-url.com\n\n"
It's that simple. Please note, that you don't give any other header-Arguments.