软件教程

ASP实现301域名重定向代码

来源: 本站    类别: 软件教程    日期: 2016/7/1

 分享一例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 %>

相关文章


Copyright © 2004 - 2024 CNHWW Inc. All Rights Reserved
石家庄市征红网络科技有限公司版权所有 邮政编码:050051
服务电话:0311-85315152 13931185013 在线客服QQ:81447932 / 81447933 邮箱: cnhww@163.com