[mod_python] Redirection with the Location Header and publisher handler

Jonathan Gardner jgardn at alumni.washington.edu
Sat Jan 12 12:37:03 EST 2002


On Friday 11 January 2002 01:31 am, Robert Sherwood wrote:
> I think you're looking for this:
>
> req.content_type = 'text/html'
> req.err_headers_out['Refresh'] = '3;http://usl/to/new/location'
> #Redirect after 3 Seconds
> req.send_http_header()
> return apache.HTTP_MOVED_PERMANENTLY
>
> Rob

It wasn't what I was looking for, and it doesn't quite work right.

I can't seem to get the Refresh header to behave properly with the default 
setting of Apache. However, this works wonderfully:

req.headers_out['Location'] = "http://www.google.com/"
return apache.HTTP_MOVED_PERMANENTLY

Of course, you can use HTTP_MOVED_TEMPORARILY or HTTP_TEMPORARY_REDIRECT is 
you like.

Jonathan



More information about the Mod_python mailing list