根据输入域名跳转不同页面

 

有域名abc.com 和 123.com,但是只有一个主机,实现如下操作:

 

访客输入:www.abc.com  访问根目录下  index.html

访客输入:www.123.com  访问根目录下  main.html

 

可在原默认主页代码前加上如下判断语句 

 

<?php   

//echo   'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];   

$sUrl = $_SERVER['SERVER_NAME'];

if ($sUrl=="www.abc.com")

{

   echo '<meta http-equiv="refresh" content="0; url=http://www.abc.com/index.html">';

}

if ($sUrl=="www.123.com")

{

   echo '<meta http-equiv="refresh" content="0; url=http://www.abc.com/main.html">';

}

?>

post by donglaifu.com | 2010年6月28日 | 归档于 [实用代码]

页面跳转php代码

 

<?php

header("location:/需要跳转的目录、页面");

?>

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

post by donglaifu.com | 2010年6月23日 | 归档于 [记网]