如何在用户注册之后自动分配给他一个二级域名?

yylzq 2009-04-25 03:49:33
就像javaeye的博客一样。比如我用abc注册,则abc.javaeye.com就立即成了我的二级域名。这是怎么实现的?
...全文
345 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wpjiyan 2009-10-24
  • 打赏
  • 举报
回复
昨个要搞这个二级域名问题 今天解决了
首先你的域名得支持泛解析 然后就是程序的问题了 你的网站做下URL重写就OK了
wudeqing 2009-05-05
  • 打赏
  • 举报
回复
你是网上申请的域名吗,修改A记录就可以了
http://www.lwcode.com
http://blog.lwcode.com
我就是这么玩的
sy_binbin 2009-04-27
  • 打赏
  • 举报
回复
那就采用URL重写了

然后再IIS的.ASP扩展里把“确认文件是否存在”的挑没了
yylzq 2009-04-25
  • 打赏
  • 举报
回复
多谢你提供的代码。不过这样只能解决只输入二级域名时的转向。但是如果我想把例如abc.javaeye.com/blog/123.asp转向到www.javaeye.com/abc/blog/123.asp就不行了。因为abc.javaeye.com/blog/123.asp泛域名解析后会转向查找服务器中/blog/123.asp文件而不是/index.asp,但该文件在服务器中是不存在的,会产生404错误。怎样才能定位到/abc/blog/123.asp呢?
sy_binbin 2009-04-25
  • 打赏
  • 举报
回复
你需要的是一个可以泛解析的顶级域名,如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()
%>
xiaojing7 2009-04-25
  • 打赏
  • 举报
回复
最简单的是用url重写来实现!!!URL重写

8,327

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 IIS
社区管理员
  • IIS
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧