I have an REST API with Yii Framework based on:
http://www.yiiframework.com/wiki/175/how-to-create-a-rest-api/
I would like to add a version of the API in the Url Rules, like:
array('api/view', 'pattern'=>'api/<version:\d+>/<model:\w+>/<id:\d+>', 'verb'=>'GET'),
How should I do that?
If you want to use one controller you could do keep the rule as you have done:
And in the controller Action check the version:
Another solution is to use custom URL rule functionnality
(there is api/version/model/id) and if it is matching depending on the api version you redirect to the right controller (ex: apiV2/view)
Code: