如何使用Google App Engine重定向所有网址 [英] How to redirect all URLs with Google App Engine

查看:167
本文介绍了如何使用Google App Engine重定向所有网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置app.yaml文件以将所有网址重定向到另一个网址?例如,我想要 http://test.appspot.com/hello http://test.appspot.com/hello28928723 重定向到 http://domain.com

How do I configure the app.yaml file to redirect all URLs to another URL? For example I want http://test.appspot.com/hello or http://test.appspot.com/hello28928723 to redirect to http://domain.com.

我目前只提供静态文件。这是我的app.yaml文件:

I am only serving static files at the moment. Here is my app.yaml file:

application: testapp
version: 1
runtime: python
api_version: 1

handlers:
- url: (.*)/
  static_files: static\1/index.html
  upload: static/index.html

- url: /
  static_dir: static


推荐答案

您可以使用python处理程序轻松重定向所有请求。类似于

you can redirect all requests easily with a python handler. Something like

class FormHandler(webapp.RequestHandler):
  def post(self):
    if processFormData(self.request):
      self.redirect("http://domain.com")

这篇关于如何使用Google App Engine重定向所有网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆