同一空間綁定多個域名而實現訪問不同的頁面代碼,PHP,jsp和ASP代碼

第一段 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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章