网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网络赚钱 > 网赚研究院
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

网赚研究院 研究网络赚钱、电子商务的新技术、动态。

Reply
 
Thread Tools Display Modes
  #1   IP: 61.139.126.97
Old 2006-10-15, 07:11 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default 多个域名绑定一个空间互不影响php

$domain_net="abc.com";
$dot_net_url="bbs/";
$dot_com_url="flash";
if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net"))
{
Header("Location: $dot_net_url");
}
else
{
Header("Location: $dot_com_url");
}
?>


再如:
Quote:
$domain_net="sutureneedles.net";
$dot_net_url="indexx.htm";
$dot_com_url="flash";
if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net"))
{
Header("Location: $dot_net_url");
}
else
{
Header("Location: $dot_com_url");
}
?>
Quote:
$domain_net="sutureneedles.net";
$dot_net_url="surgicalneedle/";
$dot_com_url="flash";
if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net"))
{
Header("Location: $dot_net_url");
}
else
{
Header("Location: $dot_com_url");
}
?>
如有端口,还要加上端口号,如端口号为81:
Quote:
$domain_net="sutureneedles.net";
$dot_net_url="surgicalneedle/";
$dot_com_url="flash";
if(($HTTP_HOST=="$domain_net")or($HTTP_HOST=="www.$domain_net:81")or($HTTP_HOST=="www.$domain_net")or($HTTP_HOST=="$domain_net:81"))
{
Header("Location: $dot_net_url");
}
else
{
Header("Location: $dot_com_url");
}
?>

Last edited by topvip : 2008-02-15 at 10:39 PM
Reply With Quote
  #2   IP: 61.139.126.97
Old 2006-10-15, 12:52 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

Quote:
switch($HTTP_HOST)
{
case "www.dns.com.cn:81":
Header("Location: dns/");
break;

default:
Header("Location: forum/");
}
?>
这个代码好, great

Last edited by topvip : 2006-10-15 at 01:53 PM
Reply With Quote
  #3   IP: 61.139.126.97
Old 2006-10-15, 01:56 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

这是一段很有用的代码,和绑定多域名的ASP代码类似,如果你只有一个PHP空间,而你又想放置多个多个站点,下面这些代码可以帮到你。

  第一个:

if($HTTP_HOST=="www.0058.net"){
Header("Location: facai.htm");
}
elseif($HTTP_HOST=="www.dns.com.cn"){
Header("Location: xinwang.htm");
}
else{
Header("Location: other.htm");
}

第二个:

if($HTTP_HOST=="www.0058.net"){
require "facai.htm";
}
elseif($HTTP_HOST=="www.dns.com.cn"){
require "xinwang.htm";
}
else{
require "other.htm";
}
Reply With Quote
  #4   IP: 61.139.126.97
Old 2006-10-15, 01:57 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

$domain_year="bbs.1001year.net";
$domain_cate="1001cate.com";
$domain_pet="1001pet.com";
$domain_1001qb="1001qb.com";
$dot_year_url="year.php";
$dot_cate_url="cate.php";
$dot_pet_url="pet.php";
$dot_1001qb_url="1001qb.php";
if(($HTTP_HOST=="$domain_year"))
{
Header("Location: $dot_year_url");
}
elseif(($HTTP_HOST=="$domain_cate")or($HTTP_HOST=="www.$domain_cate")or($HTTP_HOST=="bbs.$domain_cate"))
{
Header("Location: $dot_cate_url");
}
elseif(($HTTP_HOST=="$domain_pet")or($HTTP_HOST=="www.$domain_pet")or($HTTP_HOST=="bbs.$domain_pet"))
{
Header("Location: $dot_pet_url");
}
else
{
Header("Location: $dot_1001qb_url");
}
?>
Reply With Quote
  #5   IP: 61.139.126.97
Old 2006-10-15, 02:01 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

再写一个好代码,可以试下:
Quote:
$host=$HTTP_SERVER_VARS[SERVER_NAME];
switch ($host) {

case "www.222.com":
require_once '222.htm'; //
break;

case "www.333.com"
require_once '333.htm'; //
break;

default:
require_once 'index.html'; // 如 其他地址 的首页文件为 other.htm
break;
?>
Reply With Quote
  #6   IP: 61.139.126.97
Old 2006-10-15, 02:02 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

下面的一段代码也不错的:
Quote:
if ($_SERVER['HTTP_HOST']=="www.111.com"){
header("location: www.111.com");
}else{
header("location: www.222.com");
}

Last edited by admin : 2006-10-15 at 11:02 PM
Reply With Quote
  #7   IP: 61.139.126.97
Old 2006-10-17, 06:58 PM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default

如绑定到一个文件名:

Quote:
Header("Location: ../abc.php");
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is On

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:49 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.