Wednesday, October 01, 2003

Redirect to secure site (ASP)

The following will redirect from http://www.domain.com/path/to/file.asp to https://www.domain.com/path/to/file.asp:

VBScript:
<%
If Request.ServerVariables("HTTPS") = "off" Then
    Response.Redirect("https://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL"))
End If
%>
JScript:
<%
if(Request.ServerVariables("HTTPS") == "off"){
    Response.Redirect("https://" + Request.ServerVariables("HTTP_HOST") + Request.ServerVariables("URL"))
}
%>

No comments: