Snippet to perform HTTPS redirect
This commit is contained in:
9
snippets/httpsRedirect.md
Normal file
9
snippets/httpsRedirect.md
Normal file
@ -0,0 +1,9 @@
|
||||
### httpsRedirect
|
||||
|
||||
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
|
||||
|
||||
```js
|
||||
const httpsRedirect = () => {
|
||||
if(location.protocol !== "https:") location.replace("https://" + location.href.split("//")[1]);
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user