Location HTTP Header

P

ptn

Hi all.

I tried this stupid script on my server:

#! /usr/bin/env python

print 'Location: http://www.google.com\n'

and it didn't work, I get a blank page. I first tried the Location
header in another script, and when execution got to that point, it
would
just sort of ignore it, because the script would keep running to the
end
of the code (or stop at some unhandled exception).

I ran chmod 755 script.cgi and the cgi script is at the correct
directory, but still nothing. I think it might be an error from the
server (the old PythonWeb.org webserver), maybe it doesn't support
Location? Is that even possible? Or maybe there's some setup I
forgot
to do?

Any ideas?

Thanks a lot.
 
G

Gabriel Genellina

I tried this stupid script on my server:

#! /usr/bin/env python

print 'Location: http://www.google.com\n'

and it didn't work, I get a blank page. I first tried the Location
header in another script, and when execution got to that point, it
would
just sort of ignore it, because the script would keep running to the
end
of the code (or stop at some unhandled exception).

I assume this is a cgi script. For the Location field to be relevant, the
Status should be a 3xx (like 307 Temporary Redirect, or 302 Found)
In your case, your server probably has already sent a 200 OK response, so
Location is ignored.
Try adding a Status line -before Location above- like:
print 'Status: 302 Found"
Any ideas?

I'd use a different protocol other than CGI...
 
P

ptn

I assume this is a cgi script. For the Location field to be relevant, the  
Status should be a 3xx (like 307 Temporary Redirect, or 302 Found)
In your case, your server probably has already sent a 200 OK response, so  
Location is ignored.
Try adding a Status line -before Location above- like:
print 'Status: 302 Found"


I'd use a different protocol other than CGI...

Mmmmm no, that didn't do it. The script now is:

#! /usr/bin/env python

print 'Status: 302 Found'
print 'Location: http://www.google.com\n'

but still nothing happens, I get the same blank page.
Since the sscript is so simple, maybe it is a matter of server
configuration? Is that possible?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top