Hi guys, I’m pretty confused here and still (relatively) new to Yii (Version 1.1.14) so any help or advice is appreciated
I recently added an ssl cert to my server and it all works well except in one scenario: trying to access Yii when it redirects from http to https.
Let’s say my url is this: http__test_my application_com/folder/index.php/api/create/p1/p2
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
array('api/create', 'pattern'=>'api/create/<model:\w+>/<id:\w+>', 'verb'=>'POST')
Before I added the ssl cert, I had no problem at all accessing p1 and p2 via:
Yii::app()->getRequest()->getQuery('model');
Yii::app()->getRequest()->getQuery('id');
Now, with the ssl cert installed, if I navigate to https__test_my application_com/folder/index.php/api/create/p1/p2 I can still access the parameters ok.
I have my apache (2.2.2) vhost setup like:
VirtualHost *:80>
ServerName __test_my application_com
Redirect permanent "/" "https__test_my application_com/"
#RewriteEngine On
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https__test_my application_com$1 [R,L,QSA]
So if I use a http url it reroutes me to the https url. This works fine for all other programs on the server. However, within Yii, if I now navigate to http the parameters are suddenly null. I can’t figure out why this is happening only in Yii. Why does it work for https but not http->https?
As you can see above, I’ve experimented between Redirects and Rewrites - both give the same result.
Printing out the following:
print_r(json_encode(Yii::app()->getRequest()->isSecureConnection) . PHP_EOL);
print_r(json_encode(Yii::app()->getRequest()->getQuery('model')) . PHP_EOL);
print_r("$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" . PHP_EOL);
print_r("$_SERVER[HTTPS]");
Gives almost identical results except that model is null on http
HTTPS:
HTTP
Can anybody please point me in the right direction?
(Assume my links are correct - I wasn’t allowed post without making them look weird because it’s my first post )