Answer the question
In order to leave comments, you need to log in
How to make beautiful links in yii2 framework?
Welcome all!
Started learning yii2 and ran into a link problem. By this variant /site/view/?id=AU $_GET["id"] I can get, but how can I get $_GET["id"] also by this variant /site/view/AU and pass it to the controller? Thanks in advance!
Answer the question
In order to leave comments, you need to log in
[
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'site/index',
'/site/view/<id>' => 'site/view',
],
],
],
]
public function actionView($id){
echo $id;
}
urlManager must be configured in the config.
Everything is in the documentation. Or have you not looked?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question