CGI Redirect to another page

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

Tim Howarth <tim at> 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'

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:

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

Andrew Clover
mailto:and at

More information about the Python-list mailing list