window.location = "https://" + window.location.hostname + window.location.pathname + window.location.search;
Du vil muligvis teste, om window.location.href ikke starter med “https” før du gør det, så du omdirigerer ikke, medmindre du er nødt til det.