This is a question about Yii 2. I have already done this for Yii 1.x (previous versions), but Yii 2 seems quite different.
For a static web site, I need to set my base URL to http://www.sampledomain.com
I understand that default server name can be used. However I'd like to hard code my domain name to some one place in the framework.
In my /config/web.php (config file). I have this configuration.
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
...
Currently Yii::$app->request->BaseUrl
returns and empty.
If this is all about setting and getting Yii baseurl. Could anyone please help by showing me how the code above can change, so I can set the base URL to http://www.sampledomain.com At the moment, a Yii 2 static site takes the $_SERVER['SERVER_NAME'] of the domain, so it uses the domain being visited. However if my static site has several parked domains, I want all my internal links within the website to use one domain only. Is this possible?
In params.php add
and in controller you can call it by