title: Python redirect to URL not working
body: <p>I know there are other posts on this, but I've tried everything I can think of and still can't get a simple redirect working as a CGI script on a Linux server. I've tried 3 different methods and none of them works. I know some people will suggest removing the first two print statements after the import, but that gives me 500 Server error. All I'm trying to do is have the browser redirect to another URL when this python CGI script is called. </p>
  
  <pre><code>#!/usr/bin/env python
  import cgi, cgitb 
  print "Content-Type: text/html"
  print
  
  def go_to_url(url):
      print "HTTP/1.1 302 Found"
      print "Location: ",url,"\r\n"
      print "Connection: close \r\n"
      print " "
  
  def go_to_url2(url):
      print ('&lt;script type="text/javascript"&gt;window.location = ' + url + ';&lt;/script&gt;')
  
  def go_to_url3(url):
      print '&lt;html&gt;&lt;head&gt;&lt;script type="text/javascript"&gt;'
      print '&lt;!-- function jump(){window.location = "' + url + '" } //--&gt;'
      print '&lt;/script&gt;&lt;/head&gt;&lt;body onLoad="jump()"&gt;&lt;/body&gt;&lt;/html&gt;'
  
  url = 'http://www.yahoo.com'
  # go_to_url(url)    
  # go_to_url2(url)   
  go_to_url3(url)
  </code></pre>