900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > php根据参数跳转到指定网址 根据访问的域名跳转到指定目录的代码

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

时间:2021-01-14 07:29:49

相关推荐

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

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

ASP代码:

[code]

‘取得HTTP输入的值并付值到HTOST中

host=lcase(request.servervariables("HTTP_HOST"))

‘开始条件跳转

select CASE host

CASE "file1.admin-"

‘ 如果值HOST的值为file1.admin-则跳转到"file1/index.htm"

response.redirect "file1/index.htm"

CASE "file2.admin-"

‘ 如果值HOST的值为file2.admin-则跳转到"file2/index.htm"

response.redirect "file2/index.htm"

CASE "file3.admin-"

‘ 如果值HOST的值为file3.admin-则跳转到"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 "":

header("location:html");

break;

case "":

header("location:.html");

break;

case ".ru":

header("location:.ru.html");

break;

case ".ru":

header("location:.ru.html");

break;

case "":

header("location:.html");

break;

case "":

header("location:1111.html");

break;

}

?>

[/code]

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。