douqilai4263
2011-07-14 07:36
浏览 73
已采纳

Zend Framework中的自定义路由

I'm working on a Zend Framework API and need to follow a particular format for URLs, so I was hoping for some help regarding how to configure the routing correctly.

http://example.com/module/controller/method/actionNameHere

The above URL would need to route to the function actionNameHereAction.

Any help is appreciated.

图片转代码服务由CSDN问答提供 功能建议

我正在研究Zend Framework API,需要遵循特定的URL格式,所以我希望 关于如何正确配置路由的一些帮助。

http: //example.com/module/controller/method/actionNameHere

上述网址需要路由到actionNameHereAction函数。

感谢任何帮助。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongqiaolong9034 2011-07-20 02:03
    已采纳

    In order to produce the URLs needed, I ended up creating a custom Dispatcher, as it wasn't in the routing that URLs were being converted from actionNameHere to actionnamehereAction, but in the dispatcher. I extended the standard dispatcher and overrode this behaviour so that the action name in the URL remained case-sensitive.

    已采纳该答案
    打赏 评论
  • dph6308 2011-07-14 08:04

    The beauty of routing is that it gives you the tools for hiding exactly those pieces of information you are putting into your URL.

    Apart from that, as far as I know ZF routes by default so that your URL would end up in ...

    • the action with name method of
    • the controller with name controller of
    • the module with name module

    So either your example-URL is complicating things or you are almost there.

    B/c actionNameHere would be a paramter you could handle in your action with name "methodAction".

    But I think you want your URL to look like:

    example.com/module/controller/actionNameHere

    打赏 评论

相关推荐 更多相似问题