URL redirect
"Kory Hamzeh" <kory-oIJBLXm6W//[email protected]> Fri, 29 Jul 2011 16:00:13 -0600
| Newsgroups | gmane.comp.python.mod_python |
|---|---|
| Message-ID | <02c401cc4e3a$e4a99350$adfcb9f0$@com> |
Hi Everyone,
I'm having trouble doing a redirect using the 'Location:' keyword in the
header. My code, near the top of the handler is:
Def index(req):
# determine is we need a redirect. Set must_redirect to True is so ....
if must_redirect:
req.headers_out["HTTP/1.1"] = "301 Moved Permanently"
req.headers_out["Location:"] = "http://www.example.com/"
req.content_type = 'text/html'
return ""
I get an empty page on he browser.
I've also tried:
Def index(req):
If must_redirect:
s = """
HTTP/1.1 301 Moved Permanently
Location: http://www.example.org/
Content-Type: text/html
"""
return s
I get a page with that exact text on it.
I'm using a publisher handler.
What am I doing wrong?
Thanks,
Kory