一个空间/虚拟主机放置多个网站的转向代码(多个域名绑定一个空间)
分类:程序开发 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
%>
大家可以根据自己的需要灵活运用哦,这样只要你的空间可以绑定多个域名你就可以建多个网站了,很爽吧!
其他代码
- <%
- select case request.servervariables("server_name")
- case "www.网址.com"
- server.transfer("home.asp")
- case "en.网址.com"
- server.transfer("english.asp")
- case "cn.bclele.com"
- server.transfer("chinese.asp")
- end select
- %>
-
• 使用Aspjpeg组件,自动按宽高比例生成产品缩略图ASP代码
• 301重定向代码(ASP,ASP.NET,PHP,apache,IIS,ISAPI_Rewrite)
• 忽略JS错误代码,网页屏蔽js错误代码
• ASP如何获取当前网站地址,网页地址代码及div+css菜单应用
• ASP输出26个英文字母的方法代码
• ASP几种常见分页代码
• 1小时ASP入门,教你简单学会ASP
• asp执行出错,直接忽略错误代码
• asp导出excel文件方法
• 一个表单中如何实现多个按钮提交的方法代码