관리 메뉴

웹개발자의 기지개

[Javascript] HTTPS 로 강제 이동시키기 본문

javascript

[Javascript] HTTPS 로 강제 이동시키기

웹개발자 워니 2025. 11. 19. 09:37

 

 

if(location.hostname != "localhost") {
    if (window.location.protocol != "https:") {
        window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
    }

    if (document.location.protocol == 'http:') {
        document.location.href = document.location.href.replace('http:', 'https:');
    }
}

 

Comments