Reputation: 515
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 ?
Upvotes: 7
Views: 27274
Reputation: 201
Try to change host
'components' => array( ... 'request' => array( 'HostInfo' => 'https://mydomainname.com', ), ... ),
Upvotes: 5
Reputation: 4685
You're best off creating a custom UrlManager implementation as described here:
http://www.yiiframework.com/wiki/407/url-management-for-websites-with-secure-and-nonsecure-pages
The benefit is that your users won't have to suffer through needless double redirects every time you have a genuine redirect.
Upvotes: 0
Reputation: 1416
The "single shot" way is to set https://
in the baseUrl
parameter from the configuration:
...
'components' => array(
...
'request' => array(
'baseUrl' => ' https://mydomainname.com/site',
),
...
),
Upvotes: 0
Reputation: 9979
Edit .htaccess
file in your project folder and add these lines.It will Redirect all http traffic to https.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomainname.com/$1 [R,L]
Upvotes: 4
Reputation: 1519
Try this
Yii::app()->createAbsoluteUrl('site/index', array(), 'https');
Upvotes: 21