Subfolders and versioning

I’m currently on the setup of a api for different products, the url’s should look like the following

It seems it doesn’t work to create subfolders just like in yii1. Maybe someone could point me to the correct direction?

After reading the documentation it seems this is possible with modules and child modules. Is this the proper/best way to do that?

Hi, silentneedle!

Why you didn’t use a routing (in app config file) like: ‘/api/’ => ‘api/v1/someotherstuff’ ? :)

I’ve already tried that, but that doesn’t seem to work as yii doesn’t understand that route (I think).

Here is how I’ve tried it:

        'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'enableStrictParsing' => true,

            'rules' => [

                'productname/1.0/<controller:(\w+)>/<action:(\w+)>' => 'productname/v1/<controller>/<action>',



It seems I have to create my own url manager class as yii seems only to understand <module>/<controller>/<action> routes. Or I am doing something wrong?

Just letting you guys now that I’ve solved my problem with nested modules, you just need to make sure that you setup the namespaces correctly. You can read about nested modules here: