在这里,我试图路由页面而不在 URL 中显示其操作,
例如:网址是http://localhost/brands/1/xyz
Router::connect(
'/brands/:id/:name',
array(
'controller' => 'brands',
'action' => 'index',
'id' => '[0-9]{1,}',
'name' => '[a-z]{1,}'
)
);
它工作正常....
但我需要将id
andname
设为可选并尝试了这个:
Router::connect(
'/brands/:id/:name',
array(
'controller' => 'brands',
'action' => 'index',
'id' => '[0-9]{1,}',
'name' => '[a-z]{1,}'
)
);
根据 http://book.cakephp.org/view/542/Defining-Routes
但是,当我尝试使用此 URLhttp://localhost/brands/1
时,它会搜索操作 1,但http://localhost/brands/1/xyz
工作正常。
我的路由配置有错误吗???