Problem with linking from backend to frontend when using subdomains

My frontend url is:

My backend url is:

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+><controller:[\w-]+>' => '<controller>/index',

        'http://<site:\w+><controller:[\w-]+>/<action:[\w-]+>' => '<controller>/<action>'



<site:\w+> inside my rules is replaced with ‘fr, en, or de’ subdomains, and I am using for language localization.

I am creating links with


and $url passed is :

array(2) { [0]=> string(11) "comment/view" ["id"]=> int(112233) }

This code is always generating url :, 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

Normally this could be solved by using "baseUrl" or "hostInfo" properties. But in your case, since there are multiple languages, this idea may not be possible.

if these two properties are not set, application will append the url to the hostInfo of the Request which will be in case of backend.

You may have to modify the way you are using the rules.

One workaround is to write your own class which returns the url generated (not absolute) appended to http(s):://<<language>>

You have to follow this guide:

Basically, two UrlManagers: one for the frontend, and one for the backend.

The advanced application template provides two separate applications. That’s important.