I am creating a website which runs on https.. But when i create absolute url using
echo Yii::app()->createAbsoluteUrl('site/index');
it always return http://mydomainname.com/site/index.
my expected output is https://mydomainname.com/site/index.
How can i create a url with https ?
For example, you can use the following code to create a URL for the post/view action: use yii\helpers\Url; // Url::to() calls UrlManager::createUrl() to create a URL $url = Url::to(['post/view', 'id' => 100]);
Yii::app()->request->getUrl() method is used to get current url in Yii framework.
You can edit /path/to/application/protected/config/main. php to change the default value. Add a request component, and configure baseUrl porperty.
Try this
Yii::app()->createAbsoluteUrl('site/index', array(), 'https');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With