My frontend url is: fr.example.com
My backend url is: fr.admin.example.com
Inside my backend I want to create links to frontend, but whatever I do, it generates me link with this .admin inside of it. Here is what I am tring:
Inside my /backend/config/main.php
'frontendUrlManager' => [
'class' => 'common\components\UrlManager',
'languages' => ['fr', 'en', 'de'],
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableLanguageDetection' => false,
'rules' => [
'http://<site:\w+>.example.com/<controller:[\w-]+>' => '<controller>/index',
'http://<site:\w+>.example.com/<controller:[\w-]+>/<action:[\w-]+>' => '<controller>/<action>'
],
],
<site:\w+> inside my rules is replaced with ‘fr, en, or de’ subdomains, and I am using https://github.com/codemix/yii2-localeurls for language localization.
I am creating links with
Yii::$app->frontendUrlManager->createAbsoluteUrl($url);
and $url passed is :
array(2) { [0]=> string(11) "comment/view" ["id"]=> int(112233) }
This code is always generating url : fr.admin.examle.com, and I was expecting .admin to not be there, since I want link to frontend.
Any clues what may be wrong, or how to do this properly ? I am using Yii 2.0.9