欢迎访问雨楠喃语官方个人主页!
咨询电话:139-9180-9967
正在浏览:[转载]ASP中二级域名的转发设置
[ASP][转载]ASP中二级域名的转发设置
作者:互联网 | 来源:网络 | 发布:2010/4/25 22:48:59 | 浏览:4985
你需要的是一个可以泛解析的顶级域名,如abc.com
    这样,形如123.abc.com,bbs.abc.com,fhd.abc.com的二级域名都可以被解析到同一个地址,如指向下面这个index.asp文件,就可以实现二级域名的转向。code by niceidea
<!--#include file="conn.asp"-->
'数据库链接
<%dim host,i,subname,sql,rs,url
host=lcase(request.servervariables("HTTP_HOST"))
'取得当前域名
Function findname(hostname)
findname=""
i=instr(hostname,".")
findname=mid(hostname,1,i-1)
end Function<BR>subname=findname(host)
'截获二级域名  当然还有改进的办法 支持www.123.abc.com的域名
if subname="www" or subname&"a"="a" then response.redirect("reg.asp")
'如果获得的域名是www或者为空  则转向二级域名注册页面<BR>set rs=server.CreateObject("adodb.recordset")
sql="select * from url where subname='"&subname&"'"
rs.open sql,conn,1,1
if rs.eof then response.redirect("error.asp?e=nodata")
'如果数据库中不含有该域名 则报错
url=rs("url")
if rs("hidden")=False then response.redirect(url)
'redirect 显式转向
%>
<%if rs("hidden")=True then%>
'隐式转向 用frame实现
<head><title><%=rs("sitename")%></title>
</head>
<frameset id=f1 framespacing='0' border='0' rows='0,*' frameborder='0'><BR><frame name='header' scrolling='no' noresize' src='about:blank'>
<frame name='main' src='<%=url%>' scrolling='auto'><noframes>
<body><p></p></body></noframes></frameset>
<%end if%>
<%rs.close
set rs=nothing
conn.close
set conn=nothing
%>
'最后 关闭连接对象
相关ASP