Skip to content

Instantly share code, notes, and snippets.

@topmask
Created June 26, 2022 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topmask/9d4c6bf54ff1c6e9e8c1af3f6693a53b to your computer and use it in GitHub Desktop.
Save topmask/9d4c6bf54ff1c6e9e8c1af3f6693a53b to your computer and use it in GitHub Desktop.
将HTTP协议重定向到HTTPS协议
const httpsRedirect = () => {
if (location.protocol !== 'https:')
location.replace('https://' + location.href.split('//')[1]);
};
httpsRedirect();
// Redirect from http://mydomain.com to https://mydomain.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment