网站建设技术
PHP跳转代码,ASP跳转代码,JS跳转代码
时间:2011年04月29日 来源:互联网 作者:未知 浏览:

PHP跳转代码

情况:多个域名都指向一台服务器的同一个文件夹"NNN",要求
www.abc.com
www.123abc.com
当URL为www.abc.com的时候,页面自动跳转到NNN文件夹里的ddd
当URL为www.123abc.com的时候,页面自动跳转到NNN文件夹里的index.htm
代码

 <?php
$domain_net="wjabc.net";
$domain_com="wjabc.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');
}
?>

ASP跳转代码

 <%
host=lcase(request.servervariables("HTTP_HOST"))
'开始条件跳转
SELECT CASE host
CASE "blog.wjabc.com"
         response.redirect "/blog/"
CASE "bbs.wjabc.com"
         response.redirect "/bbs/"
case "cyle.wjabc.com"
         response.redirect "/cyle/"
case "www.abc.com"
         response.redirect "/cyle/"
CASE ELSE
         response.redirect "/main/"
END SELECT
%>

JS跳转代码

 <script>try {if( self.location == "http://abc.com/" ) {
top.location.href = "http://abc.com/directory";
}
else if( self.location == "http://123abc.com/" ) {
top.location.href = "http://123abc.com/directory";
}
else if( self.location == "http://abc.com/" ) {
top.location.href = "http://123abc.com/directory";
}
else if( self.location == "http://345abc.com/" ) {
top.location.href = "http://345abc.com/directory";
}
else {document.write ("错误的访问地址")}} catch(e) {}</script>