Search code examples
phproutesyiiyii2action

How to catch all sub requests to one URL in Yii2 framework


I'm curerently using Yii2 framework and I want to catch all requests which is taken from child path for specific URL(in my example it's myaction).

Requests are like these:

* http://my-domain.com/controller/myaction/test
* http://my-domain.com/controller/myaction/test2
* http://my-domain.com/controller/myaction/other_url

Can I get them on one parent path - /myaction?

How to configure Yii2 to get proper result?


Solution

  • Try this something like this

    '<controller:[\w\-]+>/<action:[\w\-]+>/<ident:\d+>/<token:\w+>/<module:\w+>' => '<controller>/<action>' // 2
    

    above will take/create urls like

    localhost/frontend/web/site/test-router/10/ADB/P120