A
A
AlexAll2019-01-08 12:59:37
Yii
AlexAll, 2019-01-08 12:59:37

How to make an absolute link in yii2?

I make a link in the backend to the frontend

<?=Html::a('Просмотр', Url::to([Yii::$app->urlManager->hostInfo . '/post/view' , 'slug' => $model->slug], true))?>

And it turns out such a link site.ku/admin/http://site.ku/post/view?slug=pervaa...
How to make the link absolute? site.ku/post/view?slug=pervaa-stata

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-01-08
@AlexAll

Add a second urlManager to the backend config:

'urlManager' => [
        //...
],
'frontUrlManager' => [
        'class' => 'yii\web\UrlManager',
        'baseUrl' => '',
        //...
]

and then use
For convenience, the array with the rules can be taken out as separate files and connected later in the front config and in the back config

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question