if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') { // This condition ensures that the script only runs if HTTPS is not enabled. header('Location: https://www.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit(); }