I have the following code:
public function indexAction()
{
$view = $this->_getParam('view');
echo $view;
}
T开发者_运维百科his does not print out whatever I enter after view/ unless I put index/ in front of of e.g. /index/view . Notice stackoverflow doesn't have 'index' in it's URL when we are looking at /questions/3123[any id will do].
How are they omitting the 'index' when I have to include it? I'm using Zend Framework.
See: Zend Framework Router - Usage
If you don't want to follow the generic url structure, where /controller/action/paramId/paramValue, you need to set up routes. In your config, you could put:
resources.router.routes.question.type = "Zend_Controller_Router_Route"
resources.router.routes.question.route = "question/:id"
resources.router.routes.question.defaults.controller = "question"
resources.router.routes.question.defaults.action = "index"
A url of /question/123 should now map to the index action of the Question controller and the param id would have the value 123.
精彩评论