五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網 > 365文章 > 一個空間綁定多個域名實現(xiàn)自動跳轉的幾種方法!

一個空間綁定多個域名實現(xiàn)自動跳轉的幾種方法!

文章來源:365jz.com     點擊數(shù):1773    更新時間:2010-01-19 22:45   參與評論

如果只有一個ASP空間,而你又想放置多個多個站點,這些代碼可以幫到你

第一個

程序代碼

<%
if Request.ServerVariables("SERVER_NAME")="theartemis.cn" then
response.redirect "williamlong/index.htm"
else
response.redirect "index2.htm"
end if
%>

 

第二個

程序代碼

<%
select case request.servervariables("http_host")
case "theartemis.cn" '1
Server.Transfer("v3.htm")
case "Server.Transfer("i.htm")
case "
Server.Transfer("write100.htm")
...... 繼續(xù)添加 ......
end select
%>

 


第三個


程序代碼

<%
if instr(Request.ServerVariables("SERVER_NAME"),"
theartemis.cn")>0 then
response.redirect "index.html"
elseif instr(Request.ServerVariables("SERVER_NAME")," then
response.redirect "x/index.html"
elseif instr(Request.ServerVariables("SERVER_NAME"),"
then
response.redirect "index3.html"
end if
%>

 


第四個


程序代碼

<%
if Request.ServerVariables("SERVER_NAME")="
theartemis.cn" then
response.redirect "index1.html"
elseif Request.ServerVariables("SERVER_NAME")="response.redirect "index2.html"
elseif Request.ServerVariables("SERVER_NAME")="
response.redirect "index3.html"
end if
%>

 

第五個


程序代碼

<%
if Request.ServerVariables("SERVER_NAME")="
theartemis.cn" then
Server.Transfer("williamlong.htm")
elseif Request.ServerVariables("SERVER_NAME")="Server.Transfer("moon.htm")
elseif Request.ServerVariables("SERVER_NAME")="
Server.Transfer("write100.htm")
else
Server.Transfer("other.htm")
end if
%>

 

 

這是一段很有用的代碼,和綁定多域名的ASP代碼類似,如果你只有一個PHP空間,而你又想放置多個多個站點,下面這些代碼可以幫到你

第一個:


程序代碼

if($HTTP_HOST=="theartemis.cn"){
Header("Location: moon.htm");
}
elseif($HTTP_HOST=="}
else{
Header("Location: other.htm");
}

 


第二個:

程序代碼

if($HTTP_HOST=="theartemis.cn"){
require "moon.htm";
}
elseif($HTTP_HOST=="}
else{
require "other.htm";
}

 


二用JS來實現(xiàn)多域名的跳轉

<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>

 

詳解:

1:首先,你的空間必須支持ASP,并且這個空間可以綁定下面所用到的兩個域名,然后新建一個ASP

的首頁文件,這個ASP文件中的代碼這么寫:
<%if Request.ServerVariables("SERVER_NAME")="XXXX.cn" then '第一個輸入的網址
response.redirect "index.html"                               '將它轉發(fā)到相應的文件夾
else%>

<%end if%>
<%if Request.ServerVariables("SERVER_NAME")="

"index.html"                
else%>
<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="XXXX.cn" then   '第二個輸入的網址
response.redirect "soft/index.html"                               '將它轉發(fā)到相應的文件


else%>

<%end if%>

<%if Request.ServerVariables("SERVER_NAME")="

"soft/index.html"
else%>

<%end if%>

2:寫好后將這個文件存儲為index.asp ,也就是要做你的首頁。不用擔心,這個是不會顯示的。這

個就是自動識別訪問者輸入域名的,然后依據訪問者輸入的地址進行自動跳轉的。跳轉是在瞬間完

成的,你是看不到的。呵呵

3.現(xiàn)在要做的就是把你空間中建立兩個不同的文件夾了,分別做為兩個網站的目錄。比如一個放音

樂的cd文件夾。一個放FLASH動畫的flash夾件夾。里面的內容自己放!
4.開始上傳剛才做的index.asp文件吧!把index.asp文件上傳到空間根目錄下。
5.去你的空間中將兩個域名都進行綁定好,然后就可以測試了。

如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網友會為你解答!! 點擊進入論壇

發(fā)表評論 (1773人查看0條評論)
請自覺遵守互聯(lián)網相關的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學習

業(yè)務咨詢

· 技術支持
· 服務時間:9:00-18:00
365建站網二維碼

Powered by 365建站網 RSS地圖 HTML地圖

copyright © 2013-2024 版權所有 鄂ICP備17013400號