余志国网站设计工作室是专业从事义乌网站建设、义乌外贸网站建设、义乌网站制作、义乌网站设计的专业义乌网站建设工作室,是义乌外贸网站建设专家!

一个空间/虚拟主机放置多个网站的转向代码(多个域名绑定一个空间)

分类:程序开发 Tags: 多站点 评论:2 浏览:8420 最近更新时间:2007/3/22 17:40:34

申请了几个域名,可是空间(虚拟主机)只有一个,在网上找到了这段代码,贴上来给大家分享,我的域名有:
www.yuzhiguo.com.cn
www.yuzhiguo.com
www.yuzhiguo.cn

www.poyangwz.com.cn
www.poyangwz.cn
总共五个,前三个代码里都是转到:“index.asp”页面,后两个是转到“pywz/index.asp”页面,
代码里:Response.Write( "<frameset><frame src='../pywz/index.asp'></frameset>")是使用了框架模式,对后面的路径进行了隐藏。
有不懂的地方可以加我QQ

代码如下:(保存为dns.asp放置在网站根目录,并在主机控制面板设置dns.asp为最优先访问的页面,比index.asp和index.html等都优先才行哦)
<%@LANGUAGE="VBSCRIPT"   CODEPAGE="936"%>
  <%     Option   Explicit   %>  
  <%  
  Response.Buffer   =   True    
  Response.Expires   =   -1  
  Response.ExpiresAbsolute   =   Now()   -   1    
  Response.Expires   =   0    
  Response.CacheControl   =   "no-cache"  
   
  dim   sURL  
  sURL=Request.ServerVariables("HTTP_HOST")  
  if   InStr(sURL,"=")<>0   or   InStr(sURL,"`")<>0   or   InStr(sURL,"'")<>0   or   InStr(sURL,"   ")<>0   or   InStr(sURL," ")<>0   or   InStr(sURL,"'")<>0   or   InStr(sURL,chr(34))<>0   or   InStr(sURL,"\")<>0   or   InStr(sURL,",")<>0   or   InStr(sURL,"<")<>0   or   InStr(sURL,">")<>0   then    
  Response.Status=   "404   no   found"  
  Response.End    
  end   if  
   
   if   InStr(sURL,"www.yuzhiguo.com.cn")<>0   then    
      Response.Redirect   ("index.asp") 
      Response.End    
  end   if   

    if   InStr(sURL,"yuzhiguo.com.cn")<>0   then    
      Response.Redirect   ("index.asp") 
      Response.End
  end   if  

        if   InStr(sURL,"www.yuzhiguo.com")<>0   then  
      Response.Redirect   ("index.asp")  
      Response.End    
  end   if    
       if   InStr(sURL,"yuzhiguo.com")<>0   then  
      Response.Redirect   ("index.asp")  
      Response.End    
  end   if     

    if   InStr(sURL,"www.yuzhiguo.cn")<>0   then    
      Response.Redirect   ("index.asp") 
      Response.End    
  end   if  
     
  if   InStr(sURL,"yuzhiguo.cn")<>0   then    
      Response.Redirect   ("index.asp") 
      Response.End    
  end   if 
  
    if   InStr(sURL,"www.poyangwz.com.cn")<>0   then    
Response.Write( "<frameset><frame src='../pywz/index.asp'></frameset>")
      Response.End    
  end   if  
   
     if   InStr(sURL,"poyangwz.com.cn")<>0   then    
Response.Write( "<frameset><frame src='../pywz/index.asp'></frameset>")
      Response.End    
  end   if    
 
       if   InStr(sURL,"www.poyangwz.cn")<>0   then    
Response.Write( "<frameset><frame src='../pywz/index.asp'></frameset>")
      Response.End    
  end   if    
 
         if   InStr(sURL,"poyangwz.cn")<>0   then    
Response.Write( "<frameset><frame src='../pywz/index.asp'></frameset>")
      Response.End    
  end   if        
  %> 

大家可以根据自己的需要灵活运用哦,这样只要你的空间可以绑定多个域名你就可以建多个网站了,很爽吧!

其他代码

 
  1. <%
  2. select case request.servervariables("server_name")
  3.   case "www.网址.com"
  4.     server.transfer("home.asp")
  5.   case "en.网址.com"
  6.     server.transfer("english.asp")
  7.   case "cn.bclele.com"
  8.     server.transfer("chinese.asp")
  9. end select
  10. %>

本文地址:/174/
  • 相关文章
  • 推荐文章
  • 最新文章
发表评论





您的IP:3.236.209.138,来自:
zljrodan
2. zljrodan : 有没有具体点的操作 2010/4/1 21:12:19
kite
kite : 先师,怎么跟你联系呢?呜呜。。。有问题请教 2009/9/3 17:04:13

留言

 


免费咨询
建站咨询热线
15967985565

扫一扫微信咨询
QQ: 358758308 Skype: yuzhiguo Facebook: yuzhiguo Email