Skip to content

Instantly share code, notes, and snippets.

@R4356th
Last active October 7, 2025 11:32
Show Gist options
  • Select an option

  • Save R4356th/82d1e2b6612ccc88313ea274ac6b9c4d to your computer and use it in GitHub Desktop.

Select an option

Save R4356th/82d1e2b6612ccc88313ea274ac6b9c4d to your computer and use it in GitHub Desktop.
JavaScript code to enforce https on your websites
/* Copyright 2020-25 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