Answer the question
In order to leave comments, you need to log in
How to implement urlManager from backEnd to frontEnd and vice versa?
You need to implement urlManager so that Yii::$app->urlManagerFrontEnd and Yii::$app->urlManagerBackEnd are available in backEnd and frontEnd. I found many solutions in Google, everyone does it in their own way, but I didn’t like the options. How I do:
Step 1: added 2 parameters to common/config/params.php
'domainFrontEnd' => 'yii2',
'domainBackEnd' => 'admin.yii2'
'components' => [
'urlManagerFrontEnd' => [
'class' => 'yii\web\UrlManager',
'baseUrl' => '',
'hostInfo' => $domainFrontEnd,
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
],
'urlManagerBackEnd' => [
'class' => 'yii\web\UrlManager',
'baseUrl' => '',
'hostInfo' => $domainBackEnd,
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
],
],
Yii::$app->urlManagerFrontEnd->createUrl('')
Answer the question
In order to leave comments, you need to log in
And why such dances with a tambourine? Separate admin and front by URL for transitions like example.com/admin?
Take a look at this .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question