Url routes regex question

Hi recently caught the yii bug and have been totally blown away the last few weeks since starting to play with yii.

I have decided to build a new application i have been booked for at work in yii and have a small question that i hope someone can help me with. Basically the question is in two parts.

Is it possible to optionally match part of a url route yet still match everything before it?


api/clients/add/format/(<format:.*?>) or api/clients/add

So everything after add/ would be optional and would both point to => ‘client/add’,

Also if not using named params in the regex ie <format:> is it possible to get the params as key value pairs from the url bf default in yii IE


would return the param after format in the url /format/json would return json as a value

im overiding the init() method in the controller to automatically set the format class property when the controller is requested.

Thanks for your help!

You can have two rules: one with and one without the "format" parameter.