|
|
在实践中,很多站长朋友,会问Win系列服务器不能像linux系列服务器一样,很容易实现301重定,易网主机经常整理,通过程序代码来实现此功能,相关方法如下.
使用301重定向可以把不带www的域名转向带www的域名,这样可以把权重全部指向带有www的域名,对网站优化很有帮助.
在您的数据库连接文件里加入以下代码即可实现,是不是很简单,建站从心开始,易网与您同行. <% 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 %>
也许下面的会对您有所帮助:
易网主机关于PHP用代码怎么实现301重定向 http://www.34514.cn/style/info/shownews.asp?id=436
|
|