I am creating a website that runs on https. But when I create an absolute URL using
echo Yii::app()->createAbsoluteUrl('site/index');
it always returns http://mydomainname.com/site/index .
my expected result is https://mydomainname.com/site/index .
How to create url using https?
try it
Yii::app()->createAbsoluteUrl('site/index', array(), 'https');
Modify the .htaccess file in the project folder and add these lines. It will redirect all HTTP traffic to https.
.htaccess
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://mydomainname.com/$1 [R,L]
Try changing the host
'components' => array (... 'request' => array ('HostInfo' => ' https://mydomainname.com ',), ...),
"One shot" is to set https:// in the baseUrl parameter from the configuration:
https://
baseUrl
... 'components' => array( ... 'request' => array( 'baseUrl' => ' https://mydomainname.com/site', ), ... ),
It is best to create a regular UrlManager implementation, as described here:
http://www.yiiframework.com/wiki/407/url-management-for-websites-with-secure-and-nonsecure-pages
The advantage is that your users do not have to suffer from unnecessary double redirects every time you have a genuine redirect.
Source: https://habr.com/ru/post/957315/More articles:The application unexpectedly resets each run with "You illegally mutated the NSFetchedResultsController fetch request", but the solution is annoying - iosRails filter index results using a link (no drop-down list) - ruby-on-railsLearn to write low-level drivers (Linux). - c ++How are low-level device drivers written for Linux? - linuxLaravel + AngularJS CORS not working - javascriptHow to create specific files in CMAKE every time? - cmakesplit line with first number - stringHow to save the current cursor position and load it later in Vimscript? - vimDeep GreenDao queries with n: m relationships - androidUITableView Static Cell Content Does Not Work in iOS7 - iphoneAll Articles