CGI redirection: let us discuss it further

I V wrongbad at gmail.com
Mon Mar 27 15:45:01 EST 2006


Sullivan WxPyQtKinter wrote:
> 1. Are there any method (in python of course) to redirect to a web page
> without causing a "Back" button trap(ie, when user click the back
> button on their web browser, they are redirect to their current page,
> while their hope is probably to go back to the last page they have
> seen, rather than the redirection page with a "Location: url" head and
> blank content.)?

I guess this may vary from browser to browser, but on Mozilla at least,
if your CGI script returns one of the 300 status codes, then the
redirect page doesn't get added to the browser history, and so the back
button works as expected.

> 2. Are there any method to use relative path, rather than full absolute
> URI path in "Location: url"? It is very essential for later transplant
> work, e.g.,transplant a folder of cgi scripts from one web server to
> another, with different URL.

You don't have to use absolute URLs in a Location: header returned by a
CGI script. The web server will handle relative URLs for you. See the
CGI spec:

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




More information about the Python-list mailing list