Google应用引擎重定向到绝对的uri

时间:2013-01-03 10:01:48

标签: google-app-engine redirect

我正在使用带有python和webapp2的谷歌应用引擎,我找不到使用绝对uri重定向到外部网站的方式。

例如:

class Landing(BaseHandler):
    def get(self):     
        self.render("landing.html")

    def post(self):
        name=self.request.get("name")
        if name == "yes"
            self.redirect("/")
        else:
            self.redirect("http://example.com") **This is the problem as I want to redirect to an absolute url.

self.redirect始终重定向到相对网址。我怎么能重定向到绝对URL?我认为这很容易,但我找不到方法。

2 个答案:

答案 0 :(得分:2)

适用于我, 重定向到相对网址。请检查您的主机,浏览器和缓存的配置。

GAE只是将我重新定向到我在开发和生产服务器上使用它的example.com

请注意,example.com会重定向到http://www.iana.org/domains/example/

这可能让你感到困惑。

尝试使用例如self.redirect("http://www.facebook.com")。这会将你重定向到Facebook。简单。

答案 1 :(得分:1)

另外..我想我可能已被你的代码中没有返回的事实所困扰 - 所以即使在你调用了self.redirect(...)位之后,如果你给自己写了别的东西,这可能会搞砸你的重定向。

相关问题