7

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.

clifgray
  • 4,313
  • 11
  • 67
  • 116

1 Answers1

8

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.

Lipis
  • 21,388
  • 20
  • 94
  • 121
  • so is it fine to do: self.redirect('http://www.anotherurl.com') and does that count as a 301 redirect? – clifgray Oct 01 '12 at 21:07