D
D
darknet372017-04-23 13:01:38
Yii
darknet37, 2017-04-23 13:01:38

How to make a link from a sub domain to the main domain. Yii2?

I read the documentation, but did not understand how to make a link from the admin.site.ru subdomain to site.ru.
Tell me please)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-04-23
@darknet37

I will supplement padlyuck 's answer , here is an example of the admin panel config:

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        'frontUrlManager' => [
            'class' => 'yii\web\urlManager',
            'baseUrl' => 'http://site.ru',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => require(__DIR__ . '/../../frontend/config/routes.php'),
        ],

Here is an example of creating a link
Yii::$app->frontUrlManager->createAbsoluteUrl('/img/media/product/images/'.$this->media_url);

P
padlyuck, 2017-04-23
@padlyuck

set up a second urlManager in backend and use it for frontend links https://github.com/yiisoft/yii2/issues/1578#issuec...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question