在做电子商务站点的时候,经常要求浏览器在https和http之间转化 下面我给出相应的代码:
让一个ASP页面以https开始,请在该ASP页面顶部添加如下代码:
<% Response.Buffer = True If (Request.ServerVariables("HTTPS") = "off") Then Dim xredir__, xqstr__
xredir__ = "https://" & Request.ServerVariables("SERVER_NAME") & _ Request.ServerVariables("SCRIPT_NAME") xqstr__ = Request.ServerVariables("QUERY_STRING")
if xqstr__ <> "" Then xredir__ = xredir__ & "?" & xqstr__
Response.redirect xredir__ End if %>
相反的,强迫以Http开始 请添加如下代码
<% Response.Buffer = True If (Request.ServerVariables("HTTPS") = "on") Then Dim xredir__, xqstr__
xredir__ = "http://" & Request.ServerVariables("SERVER_NAME") & _ Request.ServerVariables("SCRIPT_NAME") xqstr__ = Request.ServerVariables("QUERY_STRING")
if xqstr__ <> "" Then xredir__ = xredir__ & "?" & xqstr__
Response.redirect xredir__ End if %>
希望能对你有所帮助
|