所以我使用zend_router将我的索引页路由到我的控制器中的一个操作,而不是索引操作:
$route = new Zend_Controller_Router_Route(
'/controller/:page',
array(
'action' => 'not-index',
'controller' => 'controller',
'page' => 1,
),
);
和我的原因:页添加到路径是因为有分页在该索引和我想有分页器工作,即使用户只输入'/控制器'进入浏览器,所以它必须在那里(见:http://www.joewebster.co.uk/articles/zend-framework/7-zend-pagination-and-zend-router)…
问题是....现在控制器内的其他操作也会重定向到该页面而不是正确的
操作所以假设我输入'/controller/other-action'到浏览器,它去'controller/not-index'与page = other-action,而不是'controller/other-action'由于路由定义....是否有一种方法可以将路由器定义中的:页限制为整数?如果我输入'/controller/2'那么就会跳转到'controller/not-index'并输入page = 2如果我输入'/controller/other-action'它就会跳转到'controller/other-action'
我想你可能想看看Regex_router:http://framework.zend.com/manual/en/zend.controller.router.html zend.controller.router.routes.regex
这应该有助于你实现你的目标。恐怕标准路由器不够灵活。