根据访问的域名跳转到指定目录的代码

亲自测试这个方法可用,非常适合网站不支持子目录的空间使用,多个不同域名或子域名也可以跳到指定目录,现提供两种方法将文件命名为index.asp或index.php上传到空间首页即可。

程序代码

<%
'取得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;    
}    
?>  

本站可以测试两个域名manfufu.com和manxiaodu.com

默认分类 2021-05-21 14:57:38 通过 网页 浏览(1091)

共有0条评论!

发表评论