打印

一个空间绑定多域名实现多站点的ASP和PHP代码

一个空间绑定多域名实现多站点的ASP和PHP代码

如果只有一个ASP空间,而你又想放置多个多个站点,这些代码可以帮到你


第一个

程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.dzhai.com" then
response.redirect "williamlong/index.htm"
else
response.redirect "index2.htm"
end if
%>




第二个
程序代码
<%
select case request.servervariables("http_host")
case "www.dzhai.com" '1
Server.Transfer("v3.htm")
case "www.6id.net" '2
Server.Transfer("i.htm")
case "www.write100.com" '3
Server.Transfer("write100.htm")
...... 继续添加 ......
end select
%>




第三个
程序代码
<%
if instr(Request.ServerVariables("SERVER_NAME"),"www.dzhai.com")>0 then
response.redirect "index.asp"
elseif instr(Request.ServerVariables("SERVER_NAME"),"www.6id.net")>0 then
response.redirect "x/index.asp"
elseif instr(Request.ServerVariables("SERVER_NAME"),"www.write100.com")>0 then
response.redirect "index3.asp"
end if
%>




第四个
程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.dzhai.com" then
response.redirect "index1.asp"
elseif Request.ServerVariables("SERVER_NAME")="www.6id.net" then
response.redirect "index2.asp"
elseif Request.ServerVariables("SERVER_NAME")="www.write100.com" then
response.redirect "index3.asp"
end if
%>




第五个
程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.dzhai.com" then
Server.Transfer("williamlong.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.6id.net" then
Server.Transfer("moon.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.write100.com" then
Server.Transfer("write100.htm")
else
Server.Transfer("other.htm")
end if
%>





这是一段很有用的代码,和绑定多域名的ASP代码类似,如果你只有一个PHP空间,而你又想放置多个多个站点,下面这些代码可以帮到你

第一个:

程序代码
if($HTTP_HOST=="www.dzhai.com"){
Header("Location: moon.htm");
}
elseif($HTTP_HOST=="www.6id.net"){
Header("Location: williamlong.htm");
}
else{
Header("Location: other.htm");
}




第二个:

程序代码
if($HTTP_HOST=="www.dzhai.com"){
require "moon.htm";
}
elseif($HTTP_HOST=="www.6id.net"){
require "williamlong.htm";
}
else{
require "other.htm";
}



[ 本帖最后由 Bugkidz 于 2007-5-23 05:19 编辑 ]

TOP

不错的代码,适合虚拟主机用户~
招暑期实习编辑,北京外地均可,要求有大量在线时间,熟悉论坛常规管理,了解论坛运作模式,有独特见解!
有意者请PM本人询问投递简历邮箱地址
死后必定长眠,生前何必久睡。
我的Blog:http://chanhui.blog.ixpub.net

TOP

收藏

TOP

不错
脚在路上!

欢迎访问 我的个人空间 个人心得 文章 资料

TOP


感谢一直以来您对我们的支持!
当前时区 GMT+8, 现在时间是 2008-8-22 11:53 京ICP证060528 号

Designed By 17DST