Devil 发表于 2009-3-12 16:33:49

二级域名转发问题

我最近做了一个网站,要用到二级域名,我的程序是做到一起的就一个app,具体的配置如下,希望大家可以帮我解决。
config.php
配置如下:
$config['base_url'] = "http://test.8ther.com";
if (strtolower($_SERVER['HTTP_HOST'])=="news.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}else if (strtolower($_SERVER['HTTP_HOST'])=="comment.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}
else if (strtolower($_SERVER['HTTP_HOST'])=="auction.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}

控制器main.php
function _remap($method=null,$cid=null,$offset=0){
if (strtolower($_SERVER['HTTP_HOST'])=="news.8ther.com") {
   if($method==NULL)$method='xinwenzhongxin';
   $this->$method($cid,$offset);
   //$this->xinwenzhongxin();
}else if(strtolower($_SERVER['HTTP_HOST'])=="comment.8ther.com"){
   if (!$method)$method='pinlun';
   $this->$method($cid,$offset);

}else if(strtolower($_SERVER['HTTP_HOST'])=="auction.8ther.com"){
   if (!$method)$method='paimaipingdao';
   $this->$method($cid,$offset);
}

视图是这样的 我共用了一个
<li><a href="http://test.8ther.com">首页</a></li>
      <li>|</li>
      <li><a href="http://news.8ther.com">新闻中心</a></li>
      <li>|</li>
      <li><a href="http://comment.8ther.com">评论专题</a></li>
      <li>|</li>
      <li><a href="http://auction.8ther.com">拍卖频道</a></li>

主要问题是:
   如果我直接用$this->xinwenzhongxin();他会跳到这个栏目,如果我用
if($method==NULL)$method='xinwenzhongxin';
   $this->$method($cid,$offset); 他每次都跳到首页,希望大家帮忙。

jb86 发表于 2009-3-12 16:39:02

本帖最后由 jb86 于 2009-3-12 19:16 编辑


$config['base_url'] = "http://test.8ther.com";
if (strtolower($_SERVER['HTTP_HOST'])=="news.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}else if (strtolower($_SERVER['HTTP_HOST'])=="comment.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}
else if (strtolower($_SERVER['HTTP_HOST'])=="auction.8ther.com") {
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
}



function _remap($method=null,$cid=null,$offset=0){
if (strtolower($_SERVER['HTTP_HOST'])=="news.8ther.com") {
   if($method=='index')$method='xinwenzhongxin';
   $this->$method($cid,$offset);
   //$this->xinwenzhongxin();
}else if(strtolower($_SERVER['HTTP_HOST'])=="comment.8ther.com"){
   if ($method=='index')$method='pinlun';
   $this->$method($cid,$offset);

}else if(strtolower($_SERVER['HTTP_HOST'])=="auction.8ther.com"){
   if ($method=='index')$method='paimaipingdao';
   $this->$method($cid,$offset);
}

Devil 发表于 2009-3-12 18:19:17

大家 帮忙看看啊

Devil 发表于 2009-3-13 09:49:06

这个问题已经解决,谢谢jb86 ,hex 非常感谢!
页: [1]
查看完整版本: 二级域名转发问题