程序代码 2025-11-05 1.2k 阅读

conn.asp 里加301跳转代码

作者头像
正德明建
发布于 2025年11月07日
前端性能优化实践

<%

'========301跳转开始========

Dim An_Jump

An_Jump=True '是否开启301跳转 开启: True  关闭: False

If Lcase(Left(Request.ServerVariables("Server_name"),3))<>"www" and An_Jump Then

Response.Status="301 Moved Permanently"

Response.AddHeader "Location", GetUrl

Response.End

End If

'Response.Write  GetUrl '测试url

Function GetUrl() 

On Error Resume Next

Dim strTemp

If LCase(Request.ServerVariables("HTTPS")) = "off" Then

  strTemp = "https://"

Else 

  strTemp = "https://"

End If

If Lcase(Left(Request.ServerVariables("Server_name"),3))<>"www" Then

  strTemp = strTemp&"www."

End If

strTemp = strTemp & Request.ServerVariables("SERVER_NAME") 

If Request.ServerVariables("SERVER_PORT") <> 80 Then

strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT") 

end if

GetUrl = strTemp

End Function

'========301跳转结束========

%>


分享:
作者头像

正德明建

资深前端工程师 | 技术分享者

专注于Web开发领域多年,热爱技术分享与开源贡献。致力于记录实用技术经验,帮助更多开发者解决实际问题。