【问题标题】:Is there any way to route sub-domain to module in Google Appengine有没有办法将子域路由到 Google Appengine 中的模块
【发布时间】:2016-01-09 21:59:39
【问题描述】:

我将 dispatch.yaml 文件配置为将 /admin 路由到 Admin 模块。但我想路由我的子域来路由管理模块。 我的 dispatch.yaml 文件包含以下代码

- url: "*/admin"
  module: admin

- url: "*/admin/*"
  module: admin

在管理模块中

app = webapp2.WSGIApplication([
    routes.DomainRoute('admin.knowyouroffers.in', [
        webapp2.Route('/', handler=Admin, name='home'),
    ]),debug=settings.debug)

我在 dispatch.yaml 中尝试了以下代码。但它不能工作

- url: "admin.knowyouroffers.in/*"
  module: admin

【问题讨论】:

  • 是什么让你相信它不起作用?请发布任何指向您的结论的日志、错误、消息、输出。根据您的第一个dispatch.yaml 规则,您只是将包含路径段/admin 的请求路由到您的admin 模块。您的 wsgi 应用程序有一个处理程序 admin.knowyouroffers.in/ 但没有任何看起来像 /admin 的路由。
  • 嗨乔希,感谢您的回复。我的域管理员 CNAME 未指向 googlehosted.com。现在好了。

标签: google-app-engine webapp2 app.yaml


【解决方案1】:

您无需在管理模块中指定域,该代码仅在请求已经按照dispatch.yaml 规则路由到模块之后被调用。模块中的普通路径路由就足够了,它还允许您在在生产中部署之前测试您的代码(否则,这是唯一可以正确填写域以匹配路由规则的地方)。

检查所有模块中的请求日志以调试路由。另请参阅此问答: Appengine: Routing with dispatch.yaml

【讨论】:

  • 感谢您的回复。我的域管理员 CNAME 未指向 googlehosted.com。现在好了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-07
  • 1970-01-01
  • 2014-12-21
  • 2016-11-28
  • 1970-01-01
  • 1970-01-01
  • 2012-05-20
相关资源
最近更新 更多