为了保住网站权重不被不带www的网址分去,我们可以用301重定向来实现。我试出了个办法,可以不用再主机IIS设置,在代码中实现。在首页最前面加上这段就行。经过http头返回值测试,返回301,大功告成
<%
if instr(Request.ServerVariables("SERVER_NAME"),"www")=0 then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location","http://www."&Request.ServerVariables("SERVER_NAME")
end if
%>
注:本文发自云南电子商务研究站(http://www.xiongmaotou.com),转载请附带本说明,谢谢