子域到特定路由应用引擎

时间:2014-10-03 21:25:12

标签: python google-app-engine webapp2

我想让一个子域指向app引擎中我自定义域中的特定网址,就像这样:

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中)

2 个答案:

答案 0 :(得分:1)

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

  1. 在goddady
  2. 的CNAME别名中添加子域名
  3. 在应用引擎console
  4. 中添加子域名
  5. 将mycode修改为此
  6.   

    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)
    

答案 1 :(得分:0)

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