便宜做網(wǎng)站,不用客戶動(dòng)手特價(jià)999元,源碼整套僅需50元起

做網(wǎng)站/做SEO/解決各類網(wǎng)站問題,直接與技術(shù)談!
詳細(xì)內(nèi)容
301永久重定向的asp程序源碼
發(fā)布時(shí)間:2017-02-13 來源:本站原創(chuàng) 作者:野狼SEO團(tuán)隊(duì) 閱讀:873次
301永久重定向也可以使用asp程序來做,這跟用php做301重定向的代碼邏輯相同,只是代碼略微有區(qū)別而已:
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.zhongweijy.com.cn"
第一行是說明跳轉(zhuǎn)是301的狀態(tài),第二行是讓進(jìn)行跳轉(zhuǎn)。
下邊是野狼經(jīng)常用的301跳轉(zhuǎn)代碼完整版:
<%
Dim domain301,sndomain301=Request.ServerVariables("Server_name") // 獲取域名
//這里的3是指www的長度
if left(domain301,3)<>"www" then
Response.Status="301 Moved Permanently"
if(Request.ServerVariables("Query_String") <> "" ) then
Response.AddHeader "Location", "http://www.zhongweijy.com.cn"&Request.ServerVariables("Path_Info") &"?"&Request.ServerVariables("Query_String")
elseif(Request.ServerVariables("Path_Info") = "/index.asp" ) then
Response.AddHeader "Location", "http://www.zhongweijy.com.cn"
else
Response.AddHeader "Location", "http://www.zhongweijy.com.cn"&Request.ServerVariables("Path_Info")
end if
Response.End
end if
%>
注意事項(xiàng):
1、如果是偽靜態(tài)的網(wǎng)站,跳轉(zhuǎn)就會(huì)跳到動(dòng)態(tài)網(wǎng)址,我們建議這種情況不要用程序跳轉(zhuǎn),而是用偽靜態(tài)做301跳轉(zhuǎn)或者設(shè)置服務(wù)器來做。
2、注意首頁的默認(rèn)后綴跳轉(zhuǎn)的時(shí)候可能會(huì)帶上“index.php”或者“default.php”等。
附件:

本文作者:野狼SEO團(tuán)隊(duì)

十六年網(wǎng)站建設(shè)相關(guān)經(jīng)驗(yàn)
一站式為您提供網(wǎng)站相關(guān)服務(wù)
歡迎掃碼咨詢
還沒有人評(píng)論,快來搶個(gè)沙發(fā)!