1、先上一段我经常使用的asp代码:
<%
Dimdomain301,sn
domain301=Request.ServerVariables("Server_name")
'获取域名'这里的3是指www的长度
ifleft(domain301,3<>"www"then
Response.Status="301MovedPermanently" if(Request.ServerVariables("Query_String")<>""
)then
Response.AddHeader"Location","http://www.lichuangcheng.com"&Request.ServerVariables("Path_Info")&"?"&Request.ServerVariables("Query_String")
else
Response.AddHeader"Location","http://www.lichuangcheng.com"&Request.ServerVariables("Path_Info")
endif
Response.End
end if
%>
具体的思路就是,判断域名是不是有www,没有www的话跳转到一个添加了www的网址上。
1、另外,ASP网站也可以通过以下两种方式来配置301重定向:
第一种、配置VPS或者独立服务器
第二种、配置伪静态规则,这个相对会复杂一些,详细的方法以后野狼也会写出来。