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 routi开发者_如何学JAVAng correctly.
http://example.com/module/controller/method/actionNameHere
The above URL would need to route to the function actionNameHereAction.
Any help is appreciated.
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
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.
精彩评论