Jesus Benavent
Jesus Benavent

Reputation: 183

Google app engine redirect to an absolut uri

I am using google app engine with python and webapp2, and i can't find the way just to redirect to an external web site using an absolute uri.

For example:

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.

The self.redirect always redirects to a relative url. How could I do a redirection to an absolute url? I think it has to be easy but I can't find the way.

Upvotes: 5

Views: 763

Answers (2)

Richard Green
Richard Green

Reputation: 2062

Also.. I think I may have been bitten by the fact that there is no return in your code - so even after you've called the self.redirect(...) bit, if you write anything else to self, that may mess up your redirect.

Upvotes: 1

Jimmy Kane
Jimmy Kane

Reputation: 16825

Works fine for me and does not only redirect to a relative url. Please check your config of your host, browser and caching.

GAE just redirected me to example.com using it on my dev and production server

Take care though that example.com redirects to http://www.iana.org/domains/example/

That might be confusing you.

Try using eg self.redirect("http://www.facebook.com"). That will redirect you to facebook. Simple.

Upvotes: 2

Related Questions