Reputation: 4419
I have 4 URLs that I would like to redirect to my main page. They are all just common misspellings and I want to have my bases covered so that users can access the site even if they have a letter off. How would I go about doing this with Google App Engine?
I would imagine that I need a python handler to do the redirects but what would this look like? Any resources or examples would be great.
Upvotes: 7
Views: 2485
Reputation: 21835
You can simply use the self.redirect()
and your request will be handled correctly.
class PageHandler(webapp.RequestHandler):
def get(self):
self.redirect('/home/', permanent=True)
You can also set a custom status using the self.response.set_status(301)
. I would suggest you reading more in the docs: Redirects, Headers and Status Codes.
Upvotes: 8