域名跳轉(zhuǎn)280054016
一個(gè)空間綁定多個(gè)域名實(shí)現(xiàn)自動(dòng)跳轉(zhuǎn)的幾種方法!給出我自己使用的代碼,比如:我有域名1;域名2!我想域名直接訪問blog/index.php域名2只訪問首頁index1.html www.lnicp.co
一個(gè)空間綁定多個(gè)域名實(shí)現(xiàn)自動(dòng)跳轉(zhuǎn)的幾種方法!
給出我自己使用的代碼,比如:我有域名1;域名2!
我想域名直接訪問blog/index.php
域名2只訪問首頁index1.html www.lnicp.com http://shumaxiangji.38nvxing.com/
即可實(shí)現(xiàn)!
本人只是菜鳥,如果不對(duì)之處,請(qǐng)大家口下留情!
第一個(gè)
程序代碼
<
if Request.ServerVariables("SERVER_NAME")="www.1xx.com" then
response.redirect "williamlong/index.htm"
else
response.redirect "index2.htm"
end if
>
,第二個(gè)
程序代碼
<
select case request.servervariables("http_host")
case "www.1xx.com" '1
Server.Transfer("v3.htm")
case "www.2xx.com" '2
Server.Transfer("i.htm")
case "www.3xx.com" '3
Server.Transfer("write100.htm")
...... 繼續(xù)添加 ......
end select
>
第三個(gè)
程序代碼
<
if instr(Request.ServerVariables("SERVER_NAME"),"www.1xx.com")>0 then response.redirect "index.asp"
elseif instr(Request.ServerVariables("SERVER_NAME"),"www.2xx.com")>0 then response.redirect "x/index.asp"
elseif instr(Request.ServerVariables("SERVER_NAME"),"www.3xx.com")>0 then response.redirect "index3.asp"
end if
>
第四個(gè)
程序代碼
,<
if Request.ServerVariables("SERVER_NAME")="www.1xx.com" then
response.redirect "index1.asp"
elseif Request.ServerVariables("SERVER_NAME")="www.2xx.com" then
response.redirect "index2.asp"
elseif Request.ServerVariables("SERVER_NAME")="www.3xx.com" then
response.redirect "index3.asp"
end if
>
第五個(gè)
程序代碼
<
if Request.ServerVariables("SERVER_NAME")="www.1xx.com" then
Server.Transfer("williamlong.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.2xx.com" then
Server.Transfer("moon.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.3xx.com" then
Server.Transfer("write100.htm")
else
Server.Transfer("other.htm")
end if
>
這是一段很有用的代碼,和綁定多域名的ASP 代碼類似,如果你只有一個(gè)PHP 空間,而你又想放置多個(gè)多個(gè)站點(diǎn),下面這些代碼可以幫到你
第一個(gè):
程序代碼
if($HTTP_HOST=="www.1xx.com"){
Header("Location: moon.htm");
,}
elseif($HTTP_HOST=="www.2xx.com"){
Header("Location: williamlong.htm");
}
else{
Header("Location: other.htm");
}
第二個(gè):
程序代碼
if($HTTP_HOST=="www.1xx.com"){
require "moon.htm";
}
elseif($HTTP_HOST=="www.2xx.com"){
require "williamlong.htm";
}
else{
require "other.htm";
}
二用JS 來實(shí)現(xiàn)多域名的跳轉(zhuǎn)
,詳解:
1:首先,你的空間必須支持ASP ,并且這個(gè)空間可以綁定下面所用到的兩個(gè)域名,然后新建一個(gè)ASP
的首頁文件,這個(gè)ASP 文件中的代碼這么寫:
response.redirect "index.html" ' 將它轉(zhuǎn)發(fā)到相應(yīng)的文件夾 else> "index.html" else> 夾 else> "soft/index.html" else> 2:寫好后將這個(gè)文件存儲(chǔ)為index.asp ,也就是要做你的首頁。不用擔(dān)心,這個(gè)是不會(huì)顯示的。這 個(gè)就是自動(dòng)識(shí)別訪問者輸入域名的,然后依據(jù)訪問者輸入的地址進(jìn)行自動(dòng)跳轉(zhuǎn)的。跳轉(zhuǎn)是在瞬間完 成的,你是看不到的。呵呵 3. 現(xiàn)在要做的就是把你空間中建立兩個(gè)不同的文件夾了,分別做為兩個(gè)網(wǎng)站的目錄。比如一 個(gè)放音 樂的cd 文件夾。一個(gè)放FLASH 動(dòng)畫的flash 夾件夾。里面的內(nèi)容自己放! 4. 開始上傳剛才做的index.asp 文件吧!把index.asp 文件上傳到空間根目錄下。 5. 去你的空間中將兩個(gè)域名都進(jìn)行綁定好,然后就可以測(cè)試了。