当前位置:首页>>软件教程>>网页制作>>新闻内容  |虚拟主机 主机托管
同一空间绑定多个域名而实现访问不同的页面代码,PHP,jsp和ASP代码
作者: 发布时间:2006-12-12 13:30:24 | 【字体:

第一段 PHP 代码

<?php
switch ($_SERVER["HTTP_HOST"]) {
 case "www1.aspcn.net":
   header("location:index1.htm");
   break;
 case "www2.aspcn.net":
   header("location:index2.htm");
   break;
 case "www3.aspcn.net":
   header("location:index3.htm");
...... 继续添加 ......
   break;
}
?>

第二段 ASP 代码

1.
<%
select case request.servervariables("http_host")
case "www1.aspcn.net"
Server.Transfer("index1.htm")
case "www2.aspcn.net"
Server.Transfer("index2.htm")
case "www3.aspcn.net"
Server.Transfer("index3.htm")
...... 继续添加 ......
end select
%>

2.
<%if Request.ServerVariables("SERVER_NAME")="www.ww.com" then
response.redirect "rww/"
else%>
<%end if%>
<%if Request.ServerVariables("SERVER_NAME")=www.ww.net then
response.redirect "ww/"
else%>
<%end if%>

3.
<%
if Request.ServerVariables("SERVER_NAME")="www.rwen.com" then
response.redirect "wwwen/index.asp"
else
response.redirect "websites/"
end if
%>

4.
<%
from=lcase(Request.ServerVariables("HTTP_HOST"))
if left(from,4)="www." then
  Response.redirect("index.asp")'此处为网站首页地址
else
  response.Write( "<frameset><frame src=""blog.asp?domain="&from&"""></frameset>")
end if
%>

第三段 JSP代码:

<SCRIPT>try { if( self.location == "http://玉米一/" ) {top.location.href = "http://玉米一/目录";}

else if( self.location == "http://玉米二/" ) {top.location.href = "http://玉米二/目录";}

else if( self.location == "http://玉米三/" ) {top.location.href = "http://玉米三/目录";}

else if( self.location == "http://玉米四/" ) {top.location.href = "http://玉米四/目录";}

else { document.write ("错误的访问地址") } } catch(e) { }</SCRIPT>


文章来源:
·网店办照试行 无本经营亮剑何方
·CN域名年增长率达94.6%
·解读:“.中国”域名幕后的争夺
·极速CDN 网络时代的“磁悬浮”
·后奥运时代互联网将刮繁体风
·常用的PHP本地测试环境构建软件下载
·IE8发布与“.中国”域名系统启用日期不谋而合?
·抢滩Windows Server 2008 主机商在行动
·“解百纳”千千结难解 .TM域名商标归属未定
·电子商务与3G时代接轨