rename a zend module with routes

心不动则不痛 提交于 2019-12-11 19:47:00

问题


I have a route to rename the 'items' module to 'products', and it works in most cases, but not when there is no controller or action explicitly set in the url. For example, example.com/products does not work, while example.com/items does, and is the same as example.com/products/index/index. Any ideas how to fix it, or to make controllers and actions optional?

$router->addRoute('item-alias', new Zend_Controller_Router_Route('products/:controller/:action', array(
    'module'=>'items'
)));

Edit:

It seems to work when I changed it to

$router->addRoute('item-alias', new Zend_Controller_Router_Route('products/:controller/:action/*', array(
    'module'=>'items'
    'controller'=>'index',
    'action'=>'index'
)));

The '*' allows additional optional parameters to be appended, e.g. example.com/products/index/index/page/2


回答1:


set default values for controller and action. That way they will be optional parameters and can be skipped.



来源:https://stackoverflow.com/questions/10661232/rename-a-zend-module-with-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!