Getting base URL in Yii 2

后端 未结 10 2550
孤独总比滥情好
孤独总比滥情好 2020-12-30 19:32

I am trying to get the base URL for the project in Yii 2 but it doesn\'t seem to work. According to this page you used to be able to do:

Yii::app()->getBa         


        
10条回答
  •  温柔的废话
    2020-12-30 20:14

    Try below code. It should work. It will return base URL name

    use yii\helpers\Url;

    Url::home('http') // http://HostName/ OR Url::home('https') // https://HostName/

提交回复
热议问题