Personal tools
FAQ/HTTPS
From CMSMS
This page in: English - Deutsch - Français - Svenska - Русский - Norsk - Polski - Nederlands - Español - Lietuvių
HTTPS working
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, name it https and put this code in it ...
// 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();
}
Note: take out the :8087 if your using the default port (shared hosts do)
Note 2: If your code shows:
$config['root_url'] = str_replace('http','https',$config['root_url']);
comment this out using a "#", so:
#$config['root_url'] = str_replace('http','https',$config['root_url']);
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 ...
if(empty($_SERVER['HTTPS'])) {
$protocol = 'http://';
$port = '';
} else {
$protocol = 'https://';
$port = ':8087';
}
4. 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 the following three:
$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';
5. Finally, the last step - in your templates, add the User Defined Tag {https} on the pages you wish to be HTTPS.
Thanks goes to user gardnern.
This page in: English - Deutsch - Français - Svenska - Русский - Norsk - Polski - Nederlands - Español - Lietuvių
