REST风格不再过多介绍,下面直接上代码,配置在main.php中
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
'rules'=>array(
//Rest Uri
array('api/<controller>/index', 'pattern'=>'api/<controller:\w+>', 'verb'=>'GET'),
array('api/<controller>/create', 'pattern'=>'api/<controller:\w+>', 'verb'=>'POST'),
array('api/<controller>/view', 'pattern'=>'api/<controller:\w+>/<uuid:.*?>', 'verb'=>'GET'),
array('api/<controller>/update', 'pattern'=>'api/<controller:\w+>/<uuid:.*?>', 'verb'=>'PUT, POST'),
array('api/<controller>/delete', 'pattern'=>'api/<controller:\w+>/<uuid:.*?>', 'verb'=>'DELETE'),
//Other URLs
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<module:\w+>/<controller:\w+>/<action:\w+>/<id:.*?>'=>'<module>/<controller>/<action>',
'<module:\w+>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>',
),
),