|
我最近做了一个网站,要用到二级域名,我的程序是做到一起的就一个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); 他每次都跳到首页 ,希望大家帮忙。 |
|