设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP完成301域名重定向代码

发布时间:2022-01-08 16:02 所属栏目:120 来源:互联网
导读:分享一例asp实现301域名重定向的代码,使用301域名重定向可以把不带www的顶级域名转向到带www的域名。 代码如下: % --301域名重定向 Dim Server_Name,Path_infostr,Query_Stringstr Path_infostr=lcase(request.ServerVariables(PATH_INFO)) Server_Name=lcas
分享一例asp实现301域名重定向的代码,使用301域名重定向可以把不带www的顶级域名转向到带www的域名。
 
 
代码如下:
<%
'--301域名重定向
Dim Server_Name,Path_infostr,Query_Stringstr
Path_infostr=lcase(request.ServerVariables("PATH_INFO"))
Server_Name=lcase(request.ServerVariables("Server_Name"))
Query_Stringstr=request.ServerVariables("Query_String")
If  Query_Stringstr<>"" Then
   Query_Stringstr="?"&Query_Stringstr
IF  instr(Server_Name,"www.")<1 Then  
   Response.Status = "301 Moved Permanently"
if instr(Path_infostr,"index")>0 or  instr(Path_infostr,"default")>0  Then
  Response.AddHeader "Location","http://www."&Server_Name
Else  
   Response.AddHeader "Location","http://www."&Server_Name&Path_infostr&Query_Stringstr  
End if
  Response.End
End if %>

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读