网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   网赚研究院 (https://www.0058.net/forumdisplay.php?f=18)
-   -   多个域名绑定一个空间互不影响php (https://www.0058.net/showthread.php?t=1585)

topvip 2006-10-15 07:11 AM

多个域名绑定一个空间互不影响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:

<?php
$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:

<?php
$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:

<?php
$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");
}
?>

topvip 2006-10-15 12:52 PM

Quote:

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

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

topvip 2006-10-15 01:56 PM

这是一段很有用的代码,和绑定多域名的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";
}

topvip 2006-10-15 01:57 PM

<?php
$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");
}
?>

topvip 2006-10-15 02:01 PM

再写一个好代码,可以试下:
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;
?>

topvip 2006-10-15 02:02 PM

下面的一段代码也不错的:
Quote:

if ($_SERVER['HTTP_HOST']=="www.111.com"){
header("location: www.111.com");
}else{
header("location: www.222.com");
}

topvip 2006-10-17 06:58 PM

如绑定到一个文件名:

Quote:

Header("Location: ../abc.php");


All times are GMT +8. The time now is 02:22 PM.

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