Forcing SSL Redirect (experimental) (v. 2.9x)

If you want to use https:// links on your site, you will need to change your site settings to use https:// in the links and images, instead of http://. This will not force the site to redirect insecure links.

If you want to force the site to redirect insecure links, you can ask the web host to set up an .htaccess redirect. Or you can use the following custom PHP code. Please note:

  • This code will only redirect http://yoursite.com/systempages to https://yoursite.com/systempages.
  • This code is experimental! It has not been tested extensively, so please make sure to test all pages and processes, including inventory control, thoroughy.
  • This will only affect front end PHP pages created by the system; no direct images, external pages or non-system scripts, style sheets or files will be affected.
  • This will also not change any links you've hard coded into page, product or category descriptions or templates.
  • This will also not redirect any files in the Mals cart or storeadmin.
  • This will not redirect www.yoursite.com/systempages to yoursite.com/systempages or vice versa.
  • This will not change links or images within your pages to use https://. You will still need to change settings to use https:// links across your site.

Add the following code to the openinfo.php file in the /enc/ folder, just above the very last ?> tag on the page:

if (SB_SECURE_SITE == true) {
$is_secure = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' && filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN)) || $_SERVER['SERVER_PORT'] == 443) ? true : false;
if ($is_secure == false) {
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
 exit();
}
}

Save the page. At this point, anyone who goes to http://yoursite.com/systempages will be auto redirected to https://yoursite.com/systempages.