CGI Redirect to another page

Andrew Clover and-google at doxdesk.com
Wed Sep 24 13:38:42 CEST 2003


Tim Howarth <tim at worthy.demon.co.uk> wrote:

> print "Location: http://abcxyz/index.html"

> AFAIUI it simply sends a redirect header.

Yep; however, if you include a relative URI with no hashpart:

  print 'Location: /index.html'
  print

Then the server should send that page to the browser directly, without
sending a redirect back to the browser. This may be preferable in
some cases.

(The second print is needed to end the CGI response headers.)

Full spec here:

  http://hoohoo.ncsa.uiuc.edu/cgi/interface.html

(Using JavaScript or meta-refresh to do redirects is almost always a
really terrible idea.)

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/




More information about the Python-list mailing list