Often it's required to create links from the backend application to the frontend application. Since the frontend application may contain its own URL manager rules you need to duplicate that for the backend application by naming it differently:
return [
'components' => [
'urlManager' => [
// here is your normal backend url manager config
],
'urlManagerFrontend' => [
// here is your frontend URL manager config
],
],
];
After it is done, you can get an URL pointing to frontend like the following:
echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(...);
In order not to copy-paste frontend rules you may first move these into separate urls.php
file:
return [
// ...
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => require 'urls.php',
],
// ...
],
// ...
];
After then you may include it in urlManagerFrontend
rules as well.