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

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

问题描述

如何配置 app.yaml 文件以将所有 URL 重定向到另一个 URL?例如我想要 http://test.appspot.com/hellohttp://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: static1/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 重定向所有 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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