淘主机论坛

 找回密码
 成为淘友

QQ登录

只需一步,快速开始

KT服务器促销中 100M带宽 10T流量 超值传送门:会员注册及发帖规则 发帖看过来
查看: 3204|回复: 1

[Web] 一台服务器实现域名泛解析的方法

[复制链接]
发表于 2010-4-15 22:41:30 | 显示全部楼层 |阅读模式
泛解析,二级域名转向问题-  -                                                                                
   
  关于实现商务网站二级域名的应用`!  
   
  实现条件:  
  1、必须有一个顶级域名,而且此域名必须做好泛解析并做好指向。  
  2、必须有一独立的web服务器  。泛解析的域名指向该服务器。  
  3、在web服务器上  建一个空的主机头名的web站点。  
  4、做域名转向  
   
  什么是域名泛解析?  
              客户的顶级域名abc.com,之下所设的*.abc.com全部解析到同一个IP地址上去。比如客户设b.abc.com就会自已自动解析到与abc.com同一个IP地址上去,显示的是跟abc.com一样的页面。  
  目的是让用户可以注册abc.com为后缀虚拟三级域名系统(也可以称为免费域名)。  
   
  实现:  
              进入DNS  
              打开要做泛解析的域  (abc.com)  
              建立新域  名字为  *  
              进入这个域建立一个空主机  只输入  服务器的IP  
            OK~!  
   
  实现了泛解析就表示以后  *.abc.com的访问都会到  指定的WEB服务器上去,现在要做的就是做域名转向
  1. <!--  #i  nclude  file="conn/conn.asp"  -->  
  2.   <%  
  3.   tURL  =  Request.ServerVariables("HTTP_HOST")              '请求页面的地址  
  4.   dURL  =  left(turl,instr(tURL,".")-1)                                                            '二级域名名字  
  5.   sURL  =  dURL&"."  
  6.   sURL  =  replace(tURL,""&sURL&"","")                                                '顶级域名,也即abc.com  
  7.    
  8.   If  dURL="www"  or  durl=""  then  
  9.         Response.Redirect("默认首页")  
  10.         Response.End()  
  11.   Else  
  12.       Set  rs  =  conn.execute("select  id,username  from  [register]  where  username='"&dURL&"'")  
  13.       If    rs.eof  and  rs.bof  then  
  14.               response.Redirect("默认首页")  
  15.               response.End()  
  16.       Else  
  17.         url=  ""            '此处url  为二级域名访问的路径   
  18.           rs.close  
  19.         Set  rs  =  nothing  
  20.   %>  
  21.    
  22.    
  23.   <HTML>  
  24.   <HEAD>  
  25.   <META  http-equiv="Content-Type"  content="text/html;  charset=gb2312">  
  26.   <META  CONTENT="text/html;  CHARSET=UTF-8"  HTTP-EQUIV="Content-Type">  
  27.   <TITLE>淘主机</TITLE>  
  28.   </HEAD>  
  29.   <frameset  frameborder="0"  framespacing="0"  scrolling="no"  border="0"  marginheight="0"  marginwidth="0"  rows="0,*">  
  30.   <frame  scrolling="NO"  noresize="0"  marginwidth="0"  marginheight="0"  framespacing="0"  frameborder="0"  target="main"  name="main1"  src="/blog/about:blank">  
  31.    
  32.   <frame  scrolling="yes"  noresize="0"  marginwidth="0"  marginheight="0"  framespacing="0"  frameborder="0"  target="main1"  name="main1"  SRC="<%=url%>">  
  33.    
  34.   <noframes>  
  35.   <body>  
  36.   <p>This  page  uses  frames,  but  your  browser  doesn't  support  them.</p></body>  
  37.   </noframes>  
  38.   </frameset>  
  39.   </HTML>  
  40.   <%  
  41.       end  if  
  42.       end  if   
  43.   %>  
复制代码
把上面的代码存为index.asp放在WEB服务器的默认站点上就ok   
   
  关键的地方就是frameset  框架的使用,目的是让地址栏始终显示的是二级域名地址。  
   
  嘿嘿,写完了,第一次写这个,以前的都是  Ctrl+C,Ctrl+V  过来的,感觉写的有点摸棱两可,  
  也好拉,第一次嘛~!以后再接再厉`!
 楼主| 发表于 2010-4-15 22:42:03 | 显示全部楼层
预留
您需要登录后才可以回帖 登录 | 成为淘友

本版积分规则

小黑屋|手机版|Archiver|淘主机

GMT+8, 2024-4-24 18:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表