diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bafc2bad91d..27a7e768fbe 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -90,6 +90,25 @@ set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); require_once("master.inc.php"); +// Check if HTTPS +if ($conf->main_force_https) +{ + if (eregi('^http:',$_SERVER["SCRIPT_URI"]) && ! eregi('^https:',$_SERVER["SCRIPT_URI"])) + { + if ($_SERVER["HTTPS"] != 'on') + { + dolibarr_syslog("dolibarr_main_force_https is on but https disabled on serveur",LOG_ERR); + } + else + { + dolibarr_syslog("dolibarr_main_force_https is on, we make a redirect",LOG_DEBUG); + $newurl=eregi_replace('^http:','https:',$_SERVER["SCRIPT_URI"]); + + header("Location: ".$newurl); + exit; + } + } +} // Chargement des includes complementaire de presentation if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/menu.class.php"); // Need 11ko memory diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 9c2e30ee686..f73ba293162 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -133,6 +133,8 @@ if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swed $conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation; // Identifiant autres $conf->main_authentication = $dolibarr_main_authentication; +// Force https +$conf->main_force_https = $dolibarr_main_force_https; // Identifiant propre au client if (empty($character_set_client)) $character_set_client='ISO-8859-1'; $conf->character_set_client=$character_set_client;