drjun1994 2015-09-30 22:22
浏览 49

Appengine:使用dispatch.yaml进行路由

I have a module on Appengine say exmplemodule

And my dispatch.yaml is

application: sampleappname

dispatch:
- url: "*/"
  module: default

- url: "example.abc.com/*"
  module: examplemodule

It is working fine, so when I try to access example.abc.com/index.php it loads the index.php file normally. But what I want is that when i should access example.abc.com the index.php file should open.

How can i achieve this?

Ask me if this much of information is not sufficient to answer this question of mine.

  • 写回答

2条回答 默认 最新

  • du8980919 2015-10-01 03:14
    关注

    Note: my answer comes from the python GAE, I suspect it may be applicable to php as well, but I'm not 100% certain.

    I'm using a similar dispatch.yaml, but with just the 2nd rule.

    I just tested on my app that a request like example.abc.com is sent to examplemodule and can be seen in the GAE logs for that module (it also started an instance for the module):

    enter image description here

    From this log it appears to me that example.abc.com is actually expanded to 'example.abc.com/', which means it would be caught by your 1st rule.

    First check your logs for both modules to see which one actually gets the request.

    If indeed it goes to default I see a few things to try:

    • adding a rule specifically for example.abc.com/ before the one for */
    • reversing the order of your 2 existing rules or even dropping the 1st rule completely (unless you really want to catch directory-only URLs from example.abc.com in default) - I'd leave such rules for each module config separately, not the dispatcher file.

    Note: I also have the examplemodule's default handler treat an empty path request in the same manner as a request to the module's homepage to prevent a 404 (likely you need something different for php):

    requested_path = self.request.path_info[1:]
    if not requested_path:
        requested_path = 'home.html'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法