根据访问的域名跳转到指定目录的代码 - 鼎峰VPS 帮助中心
根据访问的域名跳转到指定目录的代码
文章分类: [web应用] 发布时间:2011-7-11 2:46 Monday 浏览(644)

以下代码存为index.asp并上传到你空间里面
 

程序代码

<%
'取得HTTP输入的值并付值到HTOST中
host=lcase(request.servervariables("HTTP_HOST"))
'开始条件跳转
select CASE host

CASE "file1.admin-s.cn"
' 如果值HOST的值为file1.admin-s.cn则跳转到"file1/index.htm"
response.redirect "file1/index.htm"

CASE "file2.admin-s.cn"
' 如果值HOST的值为file2.admin-s.cn则跳转到"file2/index.htm"
response.redirect "file2/index.htm"

CASE "file3.admin-s.cn"
' 如果值HOST的值为file3.admin-s.cn则跳转到"file3/index.htm"
response.redirect "file3/index.htm"


'如果没有符合要求的都转跳到以下页面
CASE ELSE
response.redirect "error.htm"
END select
%>

---------------------------------------------------------------------

PHP代码

<?php    
switch ($_SERVER["HTTP_HOST"])    
{    
case "mcncc.com":    
header("location:mcncc.comhtml");    
break;    
case "www.mcncc.com":    
header("location:www.mcncc.com.html");    
break;    
case "aii.net.ru":    
header("location:aii.net.ru.html");    
break;    
case "aii.org.ru":    
header("location:aii.org.ru.html");    
break;    
case "www.1111.com":    
header("location:www.1111.com.html");    
break;    
case "1111.com":    
header("location:1111.html");    
break;    
}    
?>  
标签: 域名