yii2yii2-advanced-appyii-componentsyii2-modelyii2-urlmanager

How to check is it a backend URL


'urlManagerBackend' => [
        'class' => 'yii\web\urlManager',
        'baseUrl' =>  'http://backend.test',
        'enablePrettyUrl' => true,
        'showScriptName' => true,
    ],

then I want to display the image saved under uploads directory

<img src="<?= Yii::$app->urlManagerBackend->baseUrl; ?>/uploads/logo.jpg>

the problem is this url must not be hardcode like this:

'baseUrl' =>  'http://backend.test',

Solution

  • I solve this problem by saving the full url in the database.