域名跳转280054016

一个空间绑定多个域名实现自动跳转的几种方法!给出我自己使用的代码,比如:我有域名1;域名2!我想域名直接访问blog/index.php域名2只访问首页index1.html www.lnicp.co

一个空间绑定多个域名实现自动跳转的几种方法!

给出我自己使用的代码,比如:我有域名1;域名2!

我想域名直接访问blog/index.php

域名2只访问首页index1.html www.lnicp.com http://shumaxiangji.38nvxing.com/

跳转页面

即可实现!

本人只是菜鸟,如果不对之处,请大家口下留情!

第一个

程序代码

<

if Request.ServerVariables("SERVER_NAME")="www.1xx.com" then

response.redirect "williamlong/index.htm"

else

response.redirect "index2.htm"

end if

>

,

第二个

程序代码

<

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

...... 继续添加 ......

end select

>

第三个

程序代码

<

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

>

第四个

程序代码

,

<

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

>

第五个

程序代码

<

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 代码类似,如果你只有一个PHP 空间,而你又想放置多个多个站点,下面这些代码可以帮到你

第一个:

程序代码

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");

}

第二个:

程序代码

if($HTTP_HOST=="www.1xx.com"){

require "moon.htm";

}

elseif($HTTP_HOST=="www.2xx.com"){

require "williamlong.htm";

}

else{

require "other.htm";

}

二用JS 来实现多域名的跳转

,

详解:

1:首先,你的空间必须支持ASP ,并且这个空间可以绑定下面所用到的两个域名,然后新建一个ASP

的首页文件,这个ASP 文件中的代码这么写:

response.redirect "index.html" ' 将它转发到相应的文件夹 else>

"index.html"

else>

else>

"soft/index.html"

else>

2:写好后将这个文件存储为index.asp ,也就是要做你的首页。不用担心,这个是不会显示的。这

个就是自动识别访问者输入域名的,然后依据访问者输入的地址进行自动跳转的。跳转是在瞬间完

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

3. 现在要做的就是把你空间中建立两个不同的文件夹了,分别做为两个网站的目录。比如一

,

个放音

乐的cd 文件夹。一个放FLASH 动画的flash 夹件夹。里面的内容自己放!

4. 开始上传刚才做的index.asp 文件吧!把index.asp 文件上传到空间根目录下。

5. 去你的空间中将两个域名都进行绑定好,然后就可以测试了。

标签: