asp判断客户访问用得是那个域名 然后转到对应的目录

34 篇文章 0 订阅
判断客户访问用得是那个域名 然后转到对应的目录  
asp版: 
发表多个绑定多域名的ASP代码 
如果有有一个ASP空间,而你又想放置多个多个站点,这些代码可以帮到你 
Exampale 1:
<%
if Request.ServerVariables("SERVER_NAME")="www.baidu.com" then 
response.redirect "baidu" 
else 
response.redirect "index1.html" 
end if
%> 
Exampale 2:
<% 
select case request.servervariables("http_host") 
case "www.baidu.com" '1 
Server.Transfer("com.htm") 
case "www.baidu.cn '2 
Server.Transfer("net.htm") 
case "www.baidu.net" '3 
Server.Transfer("null.htm") 
...... 继续添加 ...... 
end select 
%> 
Exampale 3:
<%
if instr(Request.ServerVariables("SERVER_NAME"),"baidu.com")>0 then 
    response.redirect "index.asp" 
else if instr(Request.ServerVariables("SERVER_NAME"),"baidu.cn")>0 then 
        response.redirect "x/index.asp" 
     else if instr(Request.ServerVariables("SERVER_NAME"),"baidu.net")>0 thenr 
                esponse.redirect "index3.asp" 
            end if 
     end if 
end if
%> 

Exampale 4:
<%
if Request.ServerVariables("SERVER_NAME")="www.baidu.com" then 
    response.redirect "main1.asp" 
else if Request.ServerVariables("SERVER_NAME")="baidu.cn" then 
        response.redirect "main1.asp" 
    else if Request.ServerVariables("SERVER_NAME")="www.baidu.net" then 
            response.redirect "/web/index.asp" 
         else if Request.ServerVariables("SERVER_NAME")="baidu.com.cn" then 
                response.redirect "/web/index.asp" 
              end if 
         end if 
    end if 
end if
%> 
Exampale 5:
<%  
'取得HTTP输入的值并付值到HTOST中 
host=lcase(request.servervariables("HTTP_HOST")) 
'开始条件跳转 
SELECT CASE host 
' 如果HOST的值是www.baidu.net就选择事件case"www.baidu.net"的命令 
CASE "www.abc.net" 
' Below is the redirect command 
response.redirect "web/" 
CASE "www.efd.com" 
response.redirect "web1/" 
'We use CASE ELSE to fix any other requests 
CASE ELSE 
response.redirect "web1/" 
END SELECT  
%>  
JS:
<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> 
PHP
<?php 
$domain_net="yeahe.com"; 
$dot_net_url="bbs/"; 
$dot_com_url="flash"; 
if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net")) 
{ 
Header("Location: $dot_net_url"); 
} 
else 
{ 
Header("Location: $dot_com_url"); 
} 
?>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值