i am working on a zend framework application, and to my surprise, the default routing is not working as expected. This is my url:
http://localhost/zend_app/public/index/test
and it is supposed to route to the index controller > test action in default module. But it is not working as expected.
When i printed the request params, i got the action as “get” and id as “test“.
array (
'controller' => 'index',
'action' => 'get',
'id' => 'test',
'module' => 'default'
)
FYI, I configured certain regex routes in my bootstrap file like this:
protected function _initRestRoute()
{
require_once 'Zend/Controller/Front.php';
require_once 'Zend/Controller/Router/Route.php';
$ctrl = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();
$router->addRoute(
'route2',
new Zend_Controller_Router_Route_Regex(
'api/([^-]*)/([^-]*)\.([^-]*)',
array(
'action' => 'index'
),
array(
1 => 'module',
2 => 'controller'
)
));
}
But none of the routes match my url above.
I could not understand what could be the issue.
Read carefully the notes under Zend Rest Route.
Zend Rest Route is designed to simplify RESTful applications, and routes requests based on the URL and request method.
In this case, you are issuing a GET request for item ‘test’ under the index controller.