HTTPS working
Posted: Thu Jul 26, 2007 2:18 pm
To get HTTPS to work, without any warnings both on the front end and admin panel, there are 3 things you need to do.
1. Get a SSL certificate and install it (most shared hosting provides provide one free)
2. Create a User Defined Tag
I called my https and put this code in it...
* take out the :8087 if your using the default port (shared hosts do)
3. Modify config.php to use HTTPS urls when necessary
If you dont do this step, you will get security warnings on all your https pages.
Add this BEFORE the $config['root_url'] variable is defined...
Now look through the config file and replace http:// with $protocol and add in the port in all the necessary config variables. There should be 3
Here is how i set mine
$config['root_url'] = $protocol.'www.mydomain.com'.$port;
$config['uploads_url'] = $protocol.'www.mydomain.com'.$port.'/uploads';
$config['image_uploads_url'] = $protocol.'www.mydomain.com'.$port.'/uploads/images';
Finally, the last step - in your templates, add your User Defined Tag( {https} ) on the pages you wish to be HTTPS.
1. Get a SSL certificate and install it (most shared hosting provides provide one free)
2. Create a User Defined Tag
I called my https and put this code in it...
Code: Select all
// Check if accessed via SSL
if(empty($_SERVER['HTTPS']))
{
// If not, redirect
$newurl = 'https://'.$_SERVER['SERVER_NAME'].':8087'.$_SERVER['REQUEST_URI'];
header("location: $newurl");
exit();
}
3. Modify config.php to use HTTPS urls when necessary
If you dont do this step, you will get security warnings on all your https pages.
Add this BEFORE the $config['root_url'] variable is defined...
Code: Select all
if(empty($_SERVER['HTTPS'])) {
$protocol = 'http://';
$port = '';
} else {
$protocol = 'https://';
$port = ':8087';
}
Here is how i set mine
$config['root_url'] = $protocol.'www.mydomain.com'.$port;
$config['uploads_url'] = $protocol.'www.mydomain.com'.$port.'/uploads';
$config['image_uploads_url'] = $protocol.'www.mydomain.com'.$port.'/uploads/images';
Finally, the last step - in your templates, add your User Defined Tag( {https} ) on the pages you wish to be HTTPS.