首页 > 开发 > Asp > 正文

ASP实现301域名重定向代码

2020-09-12 12:52:16
字体:
来源:转载
供稿:网友
分享一例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 %>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表