一、ASP
<% host=lcase(request.servervariables("HTTP_HOST")) '开始条件跳转 SELECT CASE host CASE "blog.vevb.com" response.redirect "/blog/" CASE "bbs.vevb.com" response.redirect "/bbs/" case "cyle.vevb.com" response.redirect "/cyle/" case "www.vevb.com" response.redirect "/cyle/" CASE ELSE response.redirect "/main/" END SELECT %>
二、PHP
情况:多个域名都指向一台服务器的同一个文件夹"NNN",要求
www.ddd.com
www.eee.com
当URL为www.ddd.com的时候,页面自动跳转到NNN文件夹里的ddd
当URL为www.eee.com的时候,页面自动跳转到NNN文件夹里的index.htm
代码:
<?php $domain_net="tao2t.net"; $domain_com="5300tv.com"; $dot_net_url="bbs/"; $dot_com_url="index.html"; if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net")) { Header("Location: $dot_net_url"); } elseif(($HTTP_HOST=="$domain_com")or($HTTP_HOST=="www.$domain_com")) { Header("Location: $dot_com_url"); } else { include_once('hehe.php'); } ?>
三、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>
新闻热点
疑难解答