为urlManager创建自己的类

时间:2013-11-11 22:34:53

标签: yii

这些是我对urlManager的规则。它仅适用于控制器'vijesti'。当我尝试打开任何其他页面时,它会给我404错误。 我应该为网址写自己的课程还是什么?有人可以解释一下该做什么吗?

'<controller:(vijesti)>/<action:(admin|create|update|delete|trazi)>' => 'vijesti/<action>',
'<kategorija:\w+>/<naslov:\w+>'=>'vijesti/view',            
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

2 个答案:

答案 0 :(得分:1)

问题:

规则'<kategorija:\w+>/<naslov:\w+>'=>'vijesti/view'涵盖'<controller:\w+>/<action:\w+>'=>'<controller>/<action>'

试试这个:

'<controller:(vijesti)>/<action:(admin|create|update|delete|trazi)>' => 'vijesti/<action>',
'/<kategorija:\w+>/vw_<naslov:\w+>'=>'vijesti/view',            
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

答案 1 :(得分:0)

试试这个:

'vijesti/<_a:(admin|create|update|delete|trazi|view)>' => 'vijesti/<_a>',
'<kategorija:\w+>/<naslov:\w+>'=>'vijesti/view',            
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',