0

I've got, for example, 2 routes:

  1. /site/test
  2. /site/test/foo

I need to write rules for UrlManager so it'll pass first rule to TestController and second to FooController.

Can i actually do that?

1 Answer 1

2

You are actually nesting 3 controllers, which i do not think is a really good idea, but you can do it like the following:

'urlManager' => [
    'rules' => [
        'site/test/foo/<action\w+>' => 'foo/<action>',
        'site/test/<action\w+>' => 'test/<action>',
        'site/<action\w+>' => 'site/<action>',
        ...
    ],
],
Sign up to request clarification or add additional context in comments.

2 Comments

Why is that not a good idea? What if i have /messages and /messages/comments for example? It's too much for 1 class.
it's more like i don't like having both test and foo inside site, also i usually don't use the site controller except for login, logout, error and index page, everything else i usually set on separate controllers or inside modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.