페이지 접속할 때 https로 접속했는지 http로 접속했는지 확인하는 방법을 알아보겠습니다.
<%=Response.Write Request.ServerVariables("HTTPS")%>
결과값이 on이면 https로 접속, off이면 http로 접속 입니다.
그럼 응용해서 http로 접속했을 때 https로 리다이렉트하는 방법입니다.
<%
if Request.ServerVariables("HTTPS")="off" Then
Response.Redirect("https://"&Request.ServerVariables("HTTP_HOST")&Request.ServerVariables("URL"))
End if
%>
※ Request.ServerVariables("HTTP_HOST"): 웹서버의 도메인
Request.ServerVariables("URL"): 웹서버의 URL
※ Request 객체의 ServerVariables 컬렉션을 사용하여 다양한 정보 가져오기
1. 웹서버 도메인 주소
<%=Request.ServerVariables("HTTP_HOST")%>
2. 웹서버 URL
<%=Request.ServerVariables("URL")%>
3. 이전 페이지 도메인 주소
<%=Request.ServerVariables("HTTP_REFERER")%>
4. 클라이언트의 IP 주소 :
<%=Request.ServerVariables("REMOTE_ADDR")%>
asp 반올림 함수 round 사용 방법 (0) | 2022.11.04 |
---|