Post

url 프로토콜 체크하여 http ➡️ https로 변경

http 체크하여 https로 변경

  • window.location.href

현재 페이지의 href (URL)를 반환합니다.

  • window.location.hostname

웹 호스트의 도메인 이름을 반환합니다.

  • window.location.pathname

현재 페이지의 경로와 파일 이름을 반환합니다.

  • window.location.protocol

사용 된 웹 프로토콜 (http : 또는 https :)을 반환합니다.

1
2
3
if (document.location.protocol == "http:") {
  window.location.href = window.location.href.replace("http", "https");
}


JavaScript Window Location
[javascript] https 체크

This post is licensed under CC BY 4.0 by the author.