我的cakephp路线有冲突 以下是路线
这里第二条路线不起作用。总是去第一条路线。如果顺序颠倒,那么第一条路线也在执行。
我如何解决这场冲突。
谢谢..
Router::connect('/:sluggroup/:slugsubgroup', array('controller' => 'groups',
'action' => 'main'),array('pass' => array('sluggroup','slugsubgroup')));
Router::connect('/:sluggroupevent/:action', array('controller' => 'groups',
'action' => 'addevent'),array(
'pass' => array('sluggroup')));
答案 0 :(得分:0)
我认为它确实会导致冲突,因为你的路线完全相同,它会询问2个参数。你可以用另一个词来使它独一无二。还是行动呢?比如说。
Router::connect('{insert action here or unique word}/:sluggroup/:slugsubgroup', array('controller' => 'groups',
'action' => 'main'),array('pass' => array('sluggroup','slugsubgroup')));
Router::connect('/:sluggroupevent/:action', array('controller' => 'groups',
'action' => 'addevent'),array(
'pass' => array('sluggroup')));
如果您有网址,请在网址中显示 - > / {unique word / action} / test / test它将去路线号。 1 如果您的网址是/ test / test,它将转到2号路径
更新: 基于你的片段:
Router::connect('/:sluggroupevent/:action', array('controller' => 'groups',
'action' => 'addevent'),array(
'pass' => array('sluggroup'))); //you had only one params here in this line "/:sluggroupevent/:action" -> it seems that you maean to have two params or a type error.
也许你会这样做:
Router::connect('/:sluggroupevent/addevent', array('controller' => 'groups',
'action' => 'addevent'),array(
'pass' => array('sluggroupevent'))); // it must be sluggroupevent beacuse it is the once you have specified in Router::connect('/:sluggroupevent/addevent', ..