开发者

CakePHP 1.3 Routing problem

It can't correct route from the following:

Router::connect('/ctl/act/subact/:mode/:sort'       
, array('controller' => 'ctl', 'action' => 'act_subact',
'mode' => null , 'sort' => null));

--开发者_如何学运维

$html->link('go',array('controller'=>'ctl','action'=>'act_subact'))

--

<a href="/ctl/act_subact/">go</a>

How can I do? Env:CakePHP 1.3.6 php5.2.5 on apache2


The Route /ctl/act/subact/:mode/:sort means that there must be a :mode and :sort parameter. This route would not match the URL /ctl/act/subact/. If there are optional parameters, you need to denote those with an asterisk: /ctl/act/subact/*. This route would match the URLs /ctl/act/subact/, /ctl/act/subact/foo and /ctl/act/subact/foo/bar.

If you need these optional parameters as named parameters, you'll need to create several routes for each possible "length":

Router::connect('/ctl/act/subact/:mode/:sort', array('controller' => 'ctl', 'action' => 'act_subact', 'mode' => null, 'sort' => null));
Router::connect('/ctl/act/subact/:mode', array('controller' => 'ctl', 'action' => 'act_subact', 'mode' => null));
Router::connect('/ctl/act/subact/', array('controller' => 'ctl', 'action' => 'act_subact'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜