你需要的是一个可以泛解析的顶级域名,如abc.com
这样,形如123.abc.com,bbs.abc.com,fhd.abc.com的二级域名都可以被解析到同一个地址,如指向下面这个index.asp文件,就可以实现二级域名的转向。
<!--#include file="databaseconnect.asp"-->
<%
Dim ourname
ourname="xxx.com"
on error resume next
dim host,i,subname,sql,rs,url,checkhostname
host=lcase(request.servervariables("HTTP_HOST"))
Function findname(hostname)
findname=""
i=instr(hostname,".")
findname=mid(hostname,1,i-1)
if findname="www" then
dim temp
temp=split(hostname,".")
findname=temp(1)
end if
end Function
subname=findname(host)
''''检查是否来自规定的域名 否则报错
checkhost=right(host,8)
if checkhost<>ourname then
closedata()
response.redirect("404.html")
response.end()
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from url where subname=''''"&subname&"''''"
rs.open sql,conn,1,3
if rs.eof or isnull(rs("url")) then
closedata()
response.Redirect("http://name.sfte.net/error.asp?e=nodata")
response.end()
end if
if err then
err.clear
closedata()
response.Redirect("http://name.sfte.net/error.asp?e=nodata")
response.end()
end if
If rs("deleted")=True Then
closedata()
response.redirect("http://name.sfte.net/error.asp?e=locked")
end if
''''屏蔽某些id
''''记录总转发量
conn.execute ("update [index] set clicksall=clicksall+1 where id=1")
''''记录单个域名访问量
if request.Cookies("v_date")="" or isempty(request.Cookies("v_date")) then
response.Cookies("v_date")=now()
conn.execute("update url set vtimes=vtimes+1 where subname=''''"&subname&"''''")
end if
if datediff("d",request.Cookies("v_date"),now())>0 then
response.Cookies("v_date")=now()
conn.execute("update url set vtimes=vtimes+1 where subname=''''"&subname&"''''")
end if
if rs("hidden")=False then
dim thisurl:thisurl=rs("url")
closedata()
response.redirect(thisurl)
end if
if rs("hidden")=True then
%>
<html>
<head><title><%=rs("sitename")%></title>
<meta content="<%=rs("sitename")%> xxx.com为您提供免费的二级域名" name="keywords">
<meta content="<%=rs("sitename")%>" name="description">
</head>
<frameset>
<frame src=''''<%=rs("url")%>''''>
</frameset>
</html>
<%
end If
closedata()
%>