php根据参数跳转到指定网址,根据访问的域名跳转到指定目录的代码

今天也遇到这样的情况,开始设想根据访问的域名跳转到指定目录的代码,起初还以为不能实现。没有想到度娘不愧为度娘。下面贴出网络代码,以备后用。

ASP代码:

[code]

‘取得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

%>

[/code]

PHP代码:

[code]

< ?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;

}

?>

[/code]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值