泛解析,二级域名转向问题- -

上一篇 / 下一篇  2007-04-26 11:14:42 / 个人分类:ASP

                                     

51Testing软件测试网"L {m c[

51Testing软件测试网-eY,n@$e[

51Testing软件测试网#Al1F v&x8\ Ed

关于实现商务网站二级域名的应用`!
*\d+G[Z s'{{0
6D(U;YK6]1B]8w1E0实现条件:
iX6p$|'Z01、必须有一个顶级域名,而且此域名必须做好泛解析并做好指向。51Testing软件测试网8?E.`,_o
2、必须有一独立的web服务器 。泛解析的域名指向该服务器。
`vg/f{N03、在web服务器上 建一个空的主机头名的web站点。51Testing软件测试网 IY,M-E&o1h5i
4、做域名转向51Testing软件测试网{$_'BT#W&n&H&t)n4O

p6bUBz0`0什么是域名泛解析?51Testing软件测试网},r2i:F"` K8p&zL
       客户的顶级域名abc.com,之下所设的*.abc.com全部解析到同一个IP地址上去。比如客户设b.abc.com就会自已自动解析到与abc.com同一个IP地址上去,显示的是跟abc.com一样的页面。51Testing软件测试网\kSB6oR
目的是让用户可以注册abc.com为后缀虚拟三级域名系统(也可以称为免费域名)。

Kp3|UR/Zu`051Testing软件测试网,{9o mM6^S2[

实现:
n;C"v;YP0       进入DNS51Testing软件测试网,IB2qkx~y^
       打开要做泛解析的域 (abc.com)
o0u9d `e{D.P\ I0       建立新域 名字为 *51Testing软件测试网q{i!W\
       进入这个域建立一个空主机 只输入 服务器的IP
2L\!Xu(P0@}s0      OK~!51Testing软件测试网`.Ci,nF U6W0d hF
51Testing软件测试网s6o0NV;^x
实现了泛解析就表示以后 *.abc.com的访问都会到 指定的WEB服务器上去,现在要做的就是做域名转向

Y)G B,WO051Testing软件测试网(|-C&Si_w(A"o

<!-- #include file="conn/conn.asp" -->
R P^0k`6P?W0<%
_;\/E*}k7`9M0tURL = Request.ServerVariables("HTTP_HOST")        '请求页面的地址51Testing软件测试网`J gq%Qaf9r
dURL = left(turl,instr(tURL,".")-1)                               '二级域名名字51Testing软件测试网?f/U1J,V A
sURL = dURL&"."
:Ccc#M'k@ Z ~0sURL = replace(tURL,""&sURL&"","")                         '顶级域名,也即abc.com

"V.gB O7s:T"vx B4}K0

$Epp.pq/f/wW | h0If dURL="www" or durl="" then51Testing软件测试网.YCH0dm [z#A OsI
    Response.Redirect("默认首页")
q!o\$DO1ub4E0    Response.End()51Testing软件测试网Wj-JJ(iZ0G x
Else51Testing软件测试网Jh-Eo8br XJ!B
   Set rs = conn.execute("select id,username from [register] where username='"&dURL&"'")51Testing软件测试网$L7x$il7ew?us
   If   rs.eof and rs.bof then51Testing软件测试网8Aj6u&B*r%A-R$~jV(@(m
       response.Redirect("默认首页")51Testing软件测试网'E(SF;P5m w+m
       response.End()51Testing软件测试网3y3NMwni/I:w!^w
   Else
eC+k~5tw%o PuY0    url= ""       '此处url 为二级域名访问的路径
-`o}9V5_];s(aR+_0     rs.close51Testing软件测试网%r7gO^%u
    Set rs = nothing51Testing软件测试网.p]n7|;w.okA
%>

eb Ab|0z yW0

3pRJG|(n.q051Testing软件测试网 z0]bN+c u!i)`
<HTML>51Testing软件测试网 X?'Bwap
<HEAD>
9w h0r2xHKh0<META http-equiv="Content-Type" content="text/html; charset=gb2312">51Testing软件测试网TAg6E}T6pzs
<META CONTENT="text/html; CHARSET=UTF-8" HTTP-EQUIV="Content-Type">
+@Q7bg8dDv7Ua*U0<TITLE>LD160兰德网</TITLE>
-{(Fyc8QVg0</HEAD>
Jm9AqtUcD0<frameset frameborder="0" framespacing="0" scrolling="no" border="0" marginheight="0" marginwidth="0" rows="0,*">51Testing软件测试网&q!m!XyZ-r
<frame scrolling="NO" noresize="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" target="main" name="main1" SRC="about:blank">51Testing软件测试网0Z'`V"A7[8]/K

51Testing软件测试网 v9pSwXtF

<frame scrolling="yes" noresize="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" target="main1" name="main1" SRC="<%=url%>">

g.G&qt1\7E051Testing软件测试网1j,G%psf:_

<noframes>51Testing软件测试网s~ xC1bl&dl6i1]
<body>51Testing软件测试网Y)o/\s6|7h8P2?
<p>This page uses frames, but your browser doesn't support them.</p></body>
*klE [%W5sZ%t0</noframes>51Testing软件测试网+X&FD$]b H u,x [e
</frameset>
obgh.Q-D8|\;mt0</HTML>
6vx u t9tG%pyr0<%51Testing软件测试网Vl/} U-M
   end if
j%LP7l.]]8wN-E0   end if51Testing软件测试网 l-f{3nl
%>51Testing软件测试网w|%|4h2?%e
51Testing软件测试网$r)w#T{{,jz
把上面的代码存为index.asp放在WEB服务器的默认站点上就ok51Testing软件测试网-LR}` L8^

51Testing软件测试网-I&R,sc/A.X:k IF

关键的地方就是frameset 框架的使用,目的是让地址栏始终显示的是二级域名地址。

nTAV't!R(c0

TAG: ASP

 

评分:0

我来说两句

Open Toolbar