I have a site which has a public and a private area. The private area should be served via HTTPS. I want to redirect once to an explicit HTTPS url, and then, using relative URLS, have all the links be secure. When the user logs out, I will explicitly link to an absolute non-secure HTTP URL.
My login form is shown a non-secure site via regular HTTP. My login form posts to https://www.mysite.com/login/validate , which loads using a secure connection.
My logs show that Apache is loading the URL via HTTPS and codeigniter is doing its validation correctly.
At the end of my controller function I redirect to /myaccount using CodeIgniter's URL helper's redirect method with a relative URL.
redirect('/myaccount');
This causes codeigniter to redirect to a non-HTTPS URL.
My config base_url is non-HTTPS:
$config['base_url'] = "http://www.mysite.com"
This is because some parts of the site are secure while others are not.
Is there a way to tell CodeIgniter to preserve HTTPS when doing relative redirects? Why is it assuming I want to go to a non-HTTPS site if the current controller was loaded via HTTPS and I am doing a relative redirect?
The desired behavior for me is that if I am doing relative redirect, it should preserve the protocol through which the current request was loaded. Instead, it is switching to what the config base_url has defined, even for relative redirects.