用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2891|回复: 3
收起左侧

二级域名转发问题

[复制链接]
发表于 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); 他每次都跳到首页  ,希望大家帮忙。
发表于 2009-3-12 16:39:02 | 显示全部楼层
本帖最后由 jb86 于 2009-3-12 19:16 编辑
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'];
}
 
复制代码

PHP复制代码
 
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);
}
 
复制代码
 楼主| 发表于 2009-3-12 18:19:17 | 显示全部楼层
大家 帮忙看看啊
 楼主| 发表于 2009-3-13 09:49:06 | 显示全部楼层
这个问题已经解决,谢谢jb86 ,hex 非常感谢!

本版积分规则