【问题标题】:Subdomain to specific rout app engine子域到特定路由应用引擎
【发布时间】:2014-10-03 21:25:12
【问题描述】:

我想让一个子域指向我在应用引擎中的自定义域中的特定 url,就像这样:

sub.domain.com => domain.com/sub

我在我的代码中使用 DomainRoute 并在生产中发布,但是没有用

application = webapp2.WSGIApplication([
    routes.DomainRoute('mySub.domain.com', [
            webapp2.Route('/mobile', handler=ConoceMas, name='mobile-landing'),
        ]),
    ('/', MainPage),
    ('/(es|en|fr|de)', MainPage),
    ('/sendcomments', SendComments),
    ('/subscribe', Subscribe),
    ('/mobile', ConoceMas)

当我把任何子域转到主页时。

这段代码有什么问题?又如何在localhost环境下证明呢?

PS。 在域掩码中,我将 * CNAME 配置(在 godaddy admin 中)

【问题讨论】:

    标签: python google-app-engine webapp2


    【解决方案1】:

    我按照以下步骤解决这个问题:

    1. 在goddady的CNAME别名中添加子域
    2. 在应用引擎中添加子域console
    3. 把mycode修改成这个

    application = webapp2.WSGIApplication([
    routes.DomainRoute('mySub.domain.com', [
            webapp2.Route('/', handler=ConoceMas, name='mobile-landing'), 
        ])    #entry point of the subdomain
    routes.DomainRoute('mySub.domain.com', [
            webapp2.Route('/(es|en|fr|de)', handler=ConoceMas, name='mobile-landing'), 
        ]),  #entry point of the subdomain with parameters
    ('/', MainPage),
    ('/(es|en|fr|de)', MainPage),
    ('/sendcomments', SendComments),
    ('/subscribe', Subscribe),
    ('/mobile', ConoceMas)
    

    【讨论】:

      【解决方案2】:

      您是否首先在 App Engine 中注册了您的域? here 解释得很清楚,当我实际上必须将某些内容链接到我的自定义域时,重定向工作正常。

      【讨论】:

      • 自定义域工作正常,如果我进入浏览器并看到myDomains.com 工作正常,如果转到myDomains.com/Sub 但我想输入MySub.MyDomains.com 并由myDomains.com/Sub 处理
      • 您访问浏览器并使其正常工作并不意味着 App Engine 会识别它(这现在可能不是您的问题,但您肯定必须让 App Engine “知道”它) ,并且需要完成这个过程。
      • routes.DomainRoute 不做这些事情?
      • 不是 100% 确定。我没有走那条路去做(不能帮助坏双关语,对不起:P)。我注册了它,然后使用标准配置文件(app.yaml 或 web.xml)来做路由
      猜你喜欢
      • 2021-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2016-03-30
      相关资源
      最近更新 更多