How to 301 Redirect All Requests on Google App Engine

We need two files to set this up:

app.yaml is the configuration file for the app.
main.py is a redirect script.

app.yaml

application: your-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: no

handlers:
– url: /.*
script: main.app

main.py

import webapp2

class MainPage(webapp2.RequestHandler):
def get(self):
self.redirect(“https://yourwebsite.com”, permanent=True)

app = webapp2.WSGIApplication([
(‘/.*’, MainPage),
], debug=True)

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *