同一空间绑定多个域名而实现访问不同的页面代码,PHP,jsp和ASP代码

2010-08-28 10:50:27来源:西部e网作者:

第一段 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>

关键词:域名PHPjspASP