문제

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 ?

도움이 되었습니까?

해결책

Try this

Yii::app()->createAbsoluteUrl('site/index', array(), 'https');

다른 팁

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]

Try to change host

'components' => array( ... 'request' => array( 'HostInfo' => 'https://mydomainname.com', ), ... ),

The "single shot" way is to set https:// in the baseUrl parameter from the configuration:

... 'components' => array( ... 'request' => array( 'baseUrl' => ' https://mydomainname.com/site', ), ... ),

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top