Answer the question
In order to leave comments, you need to log in
Yii2. How to specify your links in the routing rules?
Greetings!
It is necessary that a link like /show?month=02&year=2015 leads to action perform/affichesearch
UrlManager now looks like this:
'urlManager' => [
'enablePrettyUrl' => true,
//'enableStrictParsing' => true,
'showScriptName' => false,
//'suffix' => '.php',
'rules' => [
''=> '/site/index',
'actors'=> 'employees/actors',
'show'=> 'perform/afficheindex',
'show?month=<month>&year=<year>' => 'perform/affichesearch',
'<_c>/<_a>'=> '<_c>/<_a>',
'<controller:\index>' => '<controller>/index',
'<controller:>' => '<controller>/index',
],
],
Url::toRoute(['affichesearch', 'month' => $num, 'year' => $l_year]);
'show' => 'perform/afficheindex',
'show?month=<month>&year=<year>' => 'perform/affichesearch',
Answer the question
In order to leave comments, you need to log in
show?month=&year=
No need to specify enough to declare 2 parameters in the method
Redirects because you have the first show leading to 1 method and the second to another show.
Swap the conditions
'show?month=<month>&year=<year>' => 'perform/affichesearch',
'show'=> 'perform/afficheindex',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question