单空间多域名绑定,可独立访问(多版本代码)

PHP版:
先建立一个默认页面index.php
然后把A站放在A文件夹下
B站放在B文件夹下
C站放在C文件夹下

其它index.php内容如下:

<?php   
switch ($_SERVER["HTTP_HOST"])   
{   
case "www.a.com":   
header("location:a/index.php");   
break;   
case "www.b.com":   
header("location:b/index.php");   
break;   
case "www.c.com":   
header("location:c/index.php");   
break;   
}   
?>

如果用户访问 http://www.a.com 程序跳转至 空间目录下 a/index.php
如果用户访问 http://www.b.com 程序跳转至 空间目录下 b/index.php
如果用户访问 http://www.c.com 程序跳转至 空间目录下 c/index.php

利用一个php文件通过浏览器输入的域名,判定他是要打开那个文件夹里的站点,来实现一个虚拟放置多个站点
缺点:例如打开abc.com,在浏览器中看到的是abc.com/b因为站点在b目录下
其他说明:如果虚拟主机不支持子目录绑定,这是唯一有效的办法

ASP版:(准备工作同上)
index.asp内容如下:

<%if Request.ServerVariables("SERVER_NAME")="XXXX.cn" then response.redirect "index.html"  
else%>   
<%end if%>      
<%if Request.ServerVariables("SERVER_NAME")="www.XXXX.cn" then response.redirect "index.html"                    
else%>   
<%end if%>   
<%if Request.ServerVariables("SERVER_NAME")="XXXX.cn" then response.redirect "soft/index.html"   
else%>   
<%end if%>   
<%if Request.ServerVariables("SERVER_NAME")="www.XXXX.cn" thenresponse.redirect "soft/index.html"  
else%>   
<%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   
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   
%>

JSP版:(准备工作同上)
index.jsp内容如下:

<script>
try {if( self.location == "http://玉米一/" ) {   
top.location.href = "http://玉米一/目录";   
}    
else if( self.location == "http://玉米二/" ) {   
top.location.href = "http://玉米二/目录";   
}    
else if( self.location == "http://玉米三/" ) {   
top.location.href = "http://玉米三/目录";   
}    
else if( self.location == "http://玉米四/" ) {   
top.location.href = "http://玉米四/目录";   
}    
else {document.write ("错误的访问地址")}} catch(e) {}
</script>
本文链接:https://www.moyan.net.cn/study/282.html
本文标题:单空间多域名绑定,可独立访问(多版本代码)
本文声明:如无特殊说明,您可以自由转载本文,但需标注转载自莫言斋(https://www.moyan.net.cn/)。本站部分文章信息来源于互联网及公开渠道,如侵犯到您的权益,请及时联系我们(94372#qq.com)处理!
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇