一個(gè)空間綁定多個(gè)域名實(shí)現(xiàn)自動(dòng)跳轉(zhuǎn)的幾種方法
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
如果只有一個(gè)asp空間,而你又想放置多個(gè)多個(gè)站點(diǎn),這些代碼可以幫到你[br][br]第一個(gè) [br][br]程序代碼[br][br]<%[br]if request.servervariables("server_name")="dzhai.com" then[br]response.redirect "williamlong/index.htm"[br]else[br]response.redirect "index2.htm"[br]end if[br]%>[br][br][br][br]第二個(gè)[br][br]程序代碼[br][br]<%[br]select case request.servervariables("http_host")[br]case "dzhai.com" '1[br]server.transfer("v3.htm")[br]case "6id.net" '2[br]server.transfer("i.htm")[br]case "write100.com" '3[br]server.transfer("write100.htm")[br]...... 繼續(xù)添加 ......[br]end select[br]%>[br][br][br][br][br]第三個(gè)[br][br][br]程序代碼[br][br]<%[br]if instr(request.servervariables("server_name"),"dzhai.com")>0 then[br]response.redirect "index.asp"[br]elseif instr(request.servervariables("server_name"),"6id.net")>0 then[br]response.redirect "x/index.asp"[br]elseif instr(request.servervariables("server_name"),"write100.com")>0 then[br]response.redirect "index3.asp"[br]end if[br]%>[br][br][br][br][br]第四個(gè)[br][br][br]程序代碼[br][br]<%[br]if request.servervariables("server_name")="dzhai.com" then[br]response.redirect "index1.asp"[br]elseif request.servervariables("server_name")="6id.net" then[br]response.redirect "index2.asp"[br]elseif request.servervariables("server_name")="write100.com" then[br]response.redirect "index3.asp"[br]end if[br]%>[br][br][br][br]第五個(gè)[br][br][br]程序代碼[br][br]<%[br]if request.servervariables("server_name")="dzhai.com" then[br]server.transfer("williamlong.htm")[br]elseif request.servervariables("server_name")="6id.net" then[br]server.transfer("moon.htm")[br]elseif request.servervariables("server_name")="write100.com" then[br]server.transfer("write100.htm")[br]else[br]server.transfer("other.htm")[br]end if[br]%> [br][br][br][br][br][br]這是一段很有用的代碼,和綁定多域名的asp代碼類似,如果你只有一個(gè)php空間,而你又想放置多個(gè)多個(gè)站點(diǎn),下面這些代碼可以幫到你[br][br]第一個(gè):[br][br][br]程序代碼[br][br]if($http_host=="dzhai.com"){[br]header("location: moon.htm");[br]}[br]elseif($http_host=="6id.net"){[br]header("location: williamlong.htm");[br]}[br]else{[br]header("location: other.htm");[br]}[br][br][br][br][br]第二個(gè):[br][br]程序代碼[br][br]if($http_host=="dzhai.com"){[br]require "moon.htm";[br]}[br]elseif($http_host=="6id.net"){[br]require "williamlong.htm";[br]}[br]else{[br]require "other.htm";[br]}[br][br][br][br][br]二用js來(lái)實(shí)現(xiàn)多域名的跳轉(zhuǎn)[br][br][br][br][br][br]詳解:[br][br]1:首先,你的空間必須支持asp,并且這個(gè)空間可以綁定下面所用到的兩個(gè)域名,然后新建一個(gè)asp[br][br]的首頁(yè)文件,這個(gè)asp文件中的代碼這么寫: [br]<%if request.servervariables("server_name")="xxxx.cn" then '第一個(gè)輸入的網(wǎng)址[br]response.redirect "index.html" '將它轉(zhuǎn)發(fā)到相應(yīng)的文件夾[br]else%>[br][br]<%end if%>[br]<%if request.servervariables("server_name")="xxxx.cn" then response.redirect [br][br]"index.html" [br]else%>[br]<%end if%>[br][br]<%if request.servervariables("server_name")="xxxx.cn" then '第二個(gè)輸入的網(wǎng)址[br]response.redirect "soft/index.html" '將它轉(zhuǎn)發(fā)到相應(yīng)的文件[br][br]夾[br]else%>[br][br]<%end if%>[br][br]<%if request.servervariables("server_name")="xxxx.cn" thenresponse.redirect [br][br]"soft/index.html"[br]else%>[br][br]<%end if%> [br][br]2:寫好后將這個(gè)文件存儲(chǔ)為index.asp ,也就是要做你的首頁(yè)。不用擔(dān)心,這個(gè)是不會(huì)顯示的。這[br][br]個(gè)就是自動(dòng)識(shí)別訪問者輸入域名的,然后依據(jù)訪問者輸入的地址進(jìn)行自動(dòng)跳轉(zhuǎn)的。跳轉(zhuǎn)是在瞬間完[br][br]成的,你是看不到的。呵呵[br][br]3.現(xiàn)在要做的就是把你空間中建立兩個(gè)不同的文件夾了,分別做為兩個(gè)網(wǎng)站的目錄。比如一個(gè)放音[br][br]樂的cd文件夾。一個(gè)放flash動(dòng)畫的flash夾件夾。里面的內(nèi)容自己放![br]4.開始上傳剛才做的index.asp文件吧!把index.asp文件上傳到空間根目錄下。[br]5.去你的空間中將兩個(gè)域名都進(jìn)行綁定好,然后就可以測(cè)試了。
該文章在 2010/4/26 22:59:00 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |