1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| // tableau des pages qui doivent s'exécuter en https
$pages_https = array("/help/contact-us.php",
"/account/create.php",
"/account/index.php",
"/account/login.php",
"/cart/checkout.php");
// pas en local
if(stripos($_SERVER['SERVER_NAME'], ".localhost") === false) {
if($_SERVER["HTTPS"] != "on") {
if(in_array($_SERVER['PHP_SELF'], $pages_https)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
exit();
}
}
else {
if(!in_array($_SERVER['PHP_SELF'], $pages_https)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
exit();
}
}
} |