采用错误页面为动态404.asp 设置默认首页为 404.asp,程序如以下。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
url1="http://www.mediainchia.com.cn" '原域名
url2="http://www.xinshishe.com" '新域名
u1=Request.ServerVariables("SERVER_NAME")'取得网址域名地址
u2=Request.ServerVariables("URL")'获取 .com/net/等后面的UL地址
if u1="http://www.mediainchia.com.cn" then
url1="http://www.mediainchia.com.cn"
else
url1="http://mediainchia.com.cn"
end if
if Trim(Request.QueryString)<>"" then'如果有变量参数,就获取,没有就跳过
u3="?"&Trim(Request.QueryString)
end if
url="http://"&u1&u2&u3 '将获取到如http://www.71wl.com/404.asp?404;http://www.71wl.com:80/news/689.html
url=replace(url,url1&"/404.asp?404;","")
url=replace(url,url1&":80",url2)
url=replace(url,url1&"/404.asp",url2) '针对首页301跳转
url=replace(url,"index.asp","")
'Response.write(url)
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",url
if request.ServerVariables("HTTP_HOST")="xinshishe.com" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.xinshishe.com"
Response.End
end if
%>