我正在使用ZF1,并试图找出视图/脚本子目录路由无法正常工作的原因。以下是添加路由的bootstrap中的代码。请让我知道我可能有什么问题。谢谢你的时间。
public function _initRoutes()
{
$controller = Zend_Controller_Front::getInstance();
$router = $controller->getRouter();
//Route for user Account
$account = new Zend_Controller_Router_Route(
'ecommerce/account/:action',
array(
'module' => 'ecommerce',
'controller' => 'user_account',
'action' => 'index'
)
);
//Route for user Cart
$cart = new Zend_Controller_Router_Route(
'ecommerce/cart/:action',
array(
'module' => 'ecommerce',
'controller' => 'user_cart',
'action' => 'index'
)
);
//die(print_r($account));
$router->addRoute('ecommerce/user_account/', $account);
$router->addRoute('ecommerce/user_cart/', $cart);
}
答案 0 :(得分:-1)
你必须尝试这个代码
$router = Zend_Controller_Front::getInstance();
$router1 = $router->getRouter();
$router1->addRoute('category/:id/:name/*',
new Zend_Controller_Router_Route('category/:user_id/:user_name/*', array(
'controller' => 'user',
'action' => 'index'
))
);
这会对你有帮助。