(ASP)
host=lcase(request.servervariables("HTTP_HOST"))
'开始条件跳转
SELECT CASE host
CASE "blog.it19.cn"
response.redirect "/blog/"
CASE "bbs.it19.cn"
response.redirect "/bbs/"
case "cyle.it19.cn"
response.redirect "/cyle/"
case "www.it19.cn"
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="guan8.net";
$domain_com="362700.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>
评论 共有 0 条评论
暂无评论,快发表你的评论吧。