Skip to content

Instantly share code, notes, and snippets.

@R4356th
Last active July 28, 2023 09:54
Show Gist options
  • Save R4356th/82d1e2b6612ccc88313ea274ac6b9c4d to your computer and use it in GitHub Desktop.
Save R4356th/82d1e2b6612ccc88313ea274ac6b9c4d to your computer and use it in GitHub Desktop.
JavaScript code to enforce https on your websites
/* Copyright 2020-23 Radman Siddiki
Licensed under the MIT License (https://www.mit.edu/~amini/LICENSE.md) */
if (location.protocol === "http:") {
location.replace(location.href.replace("http:", "https:"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment