Answer the question
In order to leave comments, you need to log in
Yii2: Routing. How to pass a string to an action?
'foo/' => 'foo/category',
'foo/bar' => 'foo/bar'
Actually, I need to make it so that when I open the page /foo/bar I get the same controller, and when I open foo /some-value-ololo gave me "some-value-ololo".
/foo/bar in the example above works fine, but if you change the variable to any, it displays 404.
I tried to put $name in the controller parameters - to no avail.
Ideally, there should also be a third option - /foo/somevalue/anothervar/ , which outputs to the third action in the same controller, and passes somevalue to it.
Answer the question
In order to leave comments, you need to log in
/foo/bar in the example above works fine, but if you change the variable to any, it displays 404.foo - controller, bar - controller action, then there are variables, you need to configure urlManager in the config. some-value-ololo - also a foo controller action, outputs 404 because you don't have one...
[
'posts'=>'post/list',
'post/<id:\d+>'=>'post/read',
'post/<year:\d{4}>/<title>'=>'post/read',
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question