Answer the question
In order to leave comments, you need to log in
Yii2 CNC how to specify in route the received parameter from the request?
Couldn't find or frame the question correctly. Faced the following problem:
url: site.ru/module/controller/?handler=action
I want to be redirected to site.ru/module/controller/action
I tried to specify this in the rules
[
'pattern' => 'module/controller/<handler:\w+>',
'route' => 'module/controller/<handler>'
]
Answer the question
In order to leave comments, you need to log in
It is possible, as a crutch, to process and launch actions in actionIndex. The code is not exact, just to show the principle.
public function actionIndex($handler)
{
$this->runAction($handler, Yii::$app->request->getQueryParams());
}
Strange syntax. Do you specify in config/main? It seems to go without patterns, in the spirit
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'Путь который должен быть показан - /' => 'куда обращается site/index',
'<module>/<controller>/<action>' => '<module>/<controller>/<handler:action>',
],
],
You see, ?handler=action comes after a redirect from a third-party server. Therefore, it turns out a url of the form
site.ru/module/controller/?handler=action , I cannot form a url in this module/controller/action format, I need to take the value from the handler and insert it into the path.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question