Zend Framework 中两个模块的路由
我创建了控制器: module/default/index/login 我在主引导程序中添加了路由
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = new Zend_Controller_Router_Route(':action', array(
'module' => 'default',
'controller' => 'index',
));
$router->addRoute('defaulth', $route);
当我访问 url/login 时它工作正常
之后我创建了另一个控制器: module/user/index/register
当我访问 url/user/register 时它返回错误无效操作
当我访问 url/user 时/index/register 工作正常。
我必须通过 url/user/register 进行访问
请推荐任何一个。
I have created controller : module/default/index/login
I have added routing in main bootstrap
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = new Zend_Controller_Router_Route(':action', array(
'module' => 'default',
'controller' => 'index',
));
$router->addRoute('defaulth', $route);
When i accessing url/login it work fine
After that I have created another controller : module/user/index/register
When i access url/user/register it return error invalid action
When i access url/user/index/register it works fine.
I have to access with url/user/register
Please suggest any one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道路由的名称是否是自愿的(
defaulth
),但是使用default
你将覆盖 ZF 的默认主路由,即:module \:控制器\:动作\*
。尝试使用
:controller\:action\*
作为路由。I don't know if the name of the route was voluntary (
defaulth
), but withdefault
you'll overwrite ZF's default main routing, which is:module\:controller\:action\*
.Try
:controller\:action\*
as the route.