|

楼主 |
发表于 2019-4-14 17:37:11
|
显示全部楼层
如果你和我一样抠门,只有一个空间,但是你又想绑定多个域名,建多个独立的站点,现在我就让你的幻想成为现实!
如果只有一个ASP空间,而你又想放置多个多个站点,这些代码可以帮到你
第一个
程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.yxer.com" then
response.redirect "index.htm"
else
response.redirect "index2.htm"
end if
%>
第二个
程序代码
<%
select case request.servervariables("http_host")
case "www.yxer.com"
Server.Transfer("index.htm")
case "www.mei0.com"
Server.Transfer("index2.htm")
case "www.yxer.com"
Server.Transfer("index3.htm")
...... 继续添加 ......
end select
%>
第三个
程序代码
<%
if instr(Request.ServerVariables("SERVER_NAME"),"0/'>www.yxer.com")>0 then
response.redirect "index.htm"
elseif instr(Request.ServerVariables("SERVER_NAME"),"0/'>www.mei0.com")>0 then
response.redirect "index2.htm"
elseif instr(Request.ServerVariables("SERVER_NAME"),"0/'>www.yxer.com")>0 then
response.redirect "index3.htm"
end if
%>
第四个
程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.yxer.com" then
response.redirect "index.htm"
elseif Request.ServerVariables("SERVER_NAME")="www.mei0.com" then
response.redirect "index2.htm"
elseif Request.ServerVariables("SERVER_NAME")="www.yxer.com" then
response.redirect "index3.htm"
end if
%>
第五个
程序代码
<%
if Request.ServerVariables("SERVER_NAME")="www.yxer.com" then
Server.Transfer("index.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.mei0" then
Server.Transfer("index2.htm")
elseif Request.ServerVariables("SERVER_NAME")="www.yxer.com" then
Server.Transfer("index3.htm")
else
Server.Transfer("other.htm")
end if
%>
这是一段很有用的代码,和绑定多域名的ASP代码类似,如果你只有一个PHP空间,而你又想放置多个多个站点,下面这些
代码可以帮到你
第一个:
程序代码
if($HTTP_HOST=="www.yxer.com"){
Header("Location: index.htm");
}
elseif($HTTP_HOST=="www.mei0.com"){
Header("Location: index2.htm");
}
else{
Header("Location: other.htm");
}
第二个:
程序代码
if($HTTP_HOST=="www.yxer.com"){
require "index.htm";
}
elseif($HTTP_HOST=="www.mei0.com"){
require "index2.htm";
}
else{
require "other.htm";
}
如果你的空间是纯静态空间,而你又想放置多个多个站点,能不能实现呢?可以的要命,下面这些代码可以帮到你
js实现一个空间安装多个网站的方法
1、 把下面的代码保存为 domain.js ,然后上传到空间根目录
以下是代码片段:
switch(location.host){
case ’www.yxer.com’:
location.href="http://blog.163.com/libin5506@126/blog/http://www.yxer.com/index.htm"
case ’www.mei0.com’:
location.href="http://blog.163.com/libin5506@126/blog/http://www.yxer.com/index2.htm"
break;
}
2、往空间根目录的首页的 <head> 与 </head> 之间加入
<script language='javascript' src='http://blog.163.com/libin5506@126/blog/domain.js'></script>
当你输入 www.yxer.com 访问时看不到任何变化,但是当你输入 www.mei0.com 访问时,浏览器自动跳转到
www.yxer.com/index2.htm 。 这样便实现了同一个空间安装2个网站了,要实现多个网站可以依此类推。 |
|