主题:  如何用PHP实现这个ASP程序的功能?

netebuy

职务:普通成员
等级:1
金币:0.0
发贴:2
注册:2005/7/14 12:27:25
#12005/7/14 20:36:35
有一个ASP文件,有一个ASP空间,绑定了多少域名,使用不同的域名访问这个空间,可以重指定到不同的目录,现换一个PHP空间,也想实现这个功能,请教高手如何实现?

原ASP文件代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="CP_ACP"%>
<html>
<body>
<%
'取得HTTP输入的值并付值到HTOST中
host=lcase(request.servervariables("HTTP_HOST")
'开始条件跳转
SELECT CASE host
' 如果HOST的值是www.abc0.com就选择事件case"www.abc0.com"的命令
CASE "trade.netebuy.com"
' Below is the redirect command
response.redirect "trade/product/index.asp"
CASE "nantongonline.com"
' Below is the redirect command
response.redirect "index.htm"

CASE "www.nantongonline.com"
' Below is the redirect command
response.redirect "index.htm"
'We use CASE ELSE to fix any other requests
CASE ELSE
response.redirect "indexwyzg.asp"
END SELECT
%>

</body>
</html>

请教过别人说是可以用header和redirect来实现,因为初步更改如下,不过不行,希望高手帮忙改一下.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="CP_ACP"%>
<html>
<body>
<%
'取得HTTP输入的值并付值到HTOST中
host=lcase($HTTP_SERVER_VARS["HTTP_HOST"]
'开始条件跳转
SELECT CASE host
' 如果HOST的值是www.abc0.com就选择事件case"www.abc0.com"的命令
CASE "trade.netebuy.com"
' Below is the redirect command
Header("Location: $trade/product/index.asp";
CASE "nantongonline.com"
' Below is the redirect command
Header("Location: $index.htm";
'We use CASE ELSE to fix any other requests
CASE ELSE
Header("Location: $info.php";
END SELECT
%>

</body>
</html>



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#22005/7/14 21:37:34
引用:
<?php
//================================================
// Program Written By xingzhe @5d.cn, 2005.
//================================================

    $host = $_SERVER['HTTP_HOST'];

    switch ($host) {

        case "domain1":
            header("Location: domain1");
            break;

        case "domain2":
            header("Location: domain2");
            break;

        default:
            exit("invaild domain");
            break;
    }

?>


随便写了一下。。。很简单的代码结构。。。

大概就是这个样子了。。。

实际使用的时候根据您的需求增加 case 就可以。。。。



netebuy

职务:普通成员
等级:1
金币:0.0
发贴:2
注册:2005/7/14 12:27:25
#32005/7/14 22:48:13
太牛B了.高手随便搞一下就解决问题了.谢谢.



{ 在指尖上绽放的花朵 }

职务:普通成员
等级:5
金币:14.0
发贴:3209
注册:2002/7/25 21:24:11
#42005/7/14 22:59:16
netebuy在上个帖子中说
引用:
太牛B了.高手随便搞一下就解决问题了.谢谢.


高手不敢当。。能解决问题就好咯。。。