一空间放置多网站的转向代码

 

ASP代码

有时候买一个虚拟空间,足可以放N个站点,一般只要把各站点的对应域名都绑在这个虚拟空间的IP上,然后使用以下代码便可实现空间共享,站点独立 的效果  

以ASP为例:  

<%if Request.ServerVariables("SERVER_NAME")="www.gzza.com " then  
response.redirect "weba/index.asp"  
elseif Request.ServerVariables("SERVER_NAME")="bbs.gzza.com " then  
response.redirect "webb/index.asp"  
else  
response.redirect "index.asp"  
end if%>

 

这里有三个域名都绑在同一虚拟空间的IP  
www.gzza.com  
bbs.gzza.com  
she.gzza.com 

将以上代码另存为 default.asp 放在站点根目下下(假定站点默认头文档为default.asp)  

如果用户访问 www.cnz88.com  程序跳转至 空间目录下weba/index.asp  
如果用户访问 bbs.cnz88.com 程序跳转至 空间目录下webb/index.asp  
如果用户访问 she.cnz88.com程序跳转至 空间目录下 index.asp 
 

<%
host=lcase(request.servervariables("HTTP_HOST"))
Select CASE host
CASE "www.it000.com"
response.redirect "01/"
CASE "bbs.it000.com"
response.redirect "02/"
CASE ELSE
response.redirect "03/"
END Select
%>

假设01/ 02/ 03/ 为不同目录

PHP代码

<?php   
    
$arrays=array(   
        ’www.aa.com’=>’aa/index.html’,   
        ’www.bb.com’=>’bb/index.html’,   
        ’www.cc.com’=>’cc/index.html’,   
        ’www.dd.com’=>’dd/index.html’,   
        ’127.0.0.1’=>’bbs/index.php’,   
);   
$url = $arrays[$_SERVER[’HTTP_HOST’]];   
Header("Location: $url");   
?>

暂无评论

发送评论 编辑评论


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