How to do simple http redirect using Python? without using meta.
-
This depends entirely on what web framework you're using.dcrosta– dcrosta2011-03-16 04:08:16 +00:00Commented Mar 16, 2011 at 4:08
-
1for http redirect you should output header with content location: newUrl to the client. To send headers, use appropriate function on your framework.AbiusX– AbiusX2011-03-16 04:10:29 +00:00Commented Mar 16, 2011 at 4:10
-
1I am using Python as a CGI script from within the cgi-bin directory of apache.Babiker– Babiker2011-03-16 04:15:21 +00:00Commented Mar 16, 2011 at 4:15
Add a comment
|
1 Answer
To redirect using your current setup (CGI apache):
print("Location:http://newurl.com/foobar")
print # to end the CGI response headers.
3 Comments
Babiker
am getting a "Premature end of script headers" error. The print statement is my first line after #!/Python27/python.
gonjay
The url of browser(Chrome) seems not change
Alex van Es
While this works fine in Chrome on my desktop, on my ipad get a safari error saying "too many redirects"... any ideas? I tried emptying the cache on the ipad.. but no luck.