Created
June 26, 2022 07:30
-
-
Save topmask/9d4c6bf54ff1c6e9e8c1af3f6693a53b to your computer and use it in GitHub Desktop.
将HTTP协议重定向到HTTPS协议
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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