一個(gè)小技巧,在http與https之間轉(zhuǎn)化
發(fā)表時(shí)間:2024-01-10 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]在做電子商務(wù)站點(diǎn)的時(shí)候,經(jīng)常要求瀏覽器在https和http之間轉(zhuǎn)化 下面我給出相應(yīng)的代碼: 讓一個(gè)ASP頁(yè)面以https開(kāi)始,請(qǐng)?jiān)谠揂SP頁(yè)面頂部添加如下代碼: <% Response.Buffer = True If (Request.ServerVariables("HTTP...
在做電子商務(wù)站點(diǎn)的時(shí)候,經(jīng)常要求瀏覽器在https和http之間轉(zhuǎn)化
下面我給出相應(yīng)的代碼:
讓一個(gè)ASP頁(yè)面以https開(kāi)始,請(qǐng)?jiān)谠揂SP頁(yè)面頂部添加如下代碼:
<%
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
%>
相反的,強(qiáng)迫以Http開(kāi)始
請(qǐng)?zhí)砑尤缦麓a
<%
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
%>
希望能對(duì)你有所幫助