[mod_python] Internal redirect (to the same server)

vio vmilitaru at sympatico.ca
Thu Aug 15 14:02:27 EST 2002


I believe that each browser handles the redirect HTTP messages a little 
differently, so redirection is browser-dependant.
But the question is rather how to by-pass the redirect altogether.
I believe you can do that by writing directly to the browser.

So instead of something like:
 _REQUEST.headers_out['location'] = 'http://' + your_other_virtual_server
 _REQUEST.status = apache.HTTP_MOVED_PERMANENTLY
 _REQUEST.send_http_header()
 raise apache.SERVER_RETURN, apache.OK

you would do something like:
 _REQUEST.headers_out.add('Pragma','no-cache')
 _REQUEST.headers_out.add( your other headers here)
 _REQUEST.send_http_header()

 _REQUEST.write(some_html_document)
 raise apache.SERVER_RETURN, apache.OK

where :
 some_html_document = """\
 <HTML>
 <HEAD><TITLE> Hello </TITLE></HEAD>
 <BODY>
 ...
 </BODY>
 </HTML>
 """

Hope this helps,
Vio


* Grant Beasley <gbeasley at tsa.ac.za> [020815 13:26]:
> Hi
> 
> If I want to redirect the browser to another URL on my server, I can use a
> HTTP redirect, but as I understand it, the redirect gets sent to the
> browser, which then goes to the new URL, i.e. comes back to my server. I
> want to be able to tell apache to serve another URL, without the useless
> loop back to the browser.
> 
> Is this possible? And if so, could you give me a few pointers?
> 
> Secondly, what is the difference between HTTP_MOVED_TEMPORARILY and
> HTTP_TEMPORARY_REDIRECT?
> 
> Thanks
> Grant Beasley
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list