我有一个 codeigniter multistie 安装,我有这样的代码,我可以用这样的链接为网站提供服务
site.com/sites/sitename/controller/function/vars site.com/controller/function/vars/
subdom.site.com/controller/function/vars
挑战在于,路由
$route['sites/([^/]+)/(.*)'] = '$2';
$route['default_controller'] = "content";
我开始使用链接,例如
site.com/sites/sitename/controller/function/vars site.com/controller/function/vars
我去的时候按主意
www.site.com/sites/sitename/
默认控制器未加载。
我制作了 config.php,以便关于链接结构,当我访问链接时
site.com/sites/sitename/controller/function/vars
然后
$config['base_url']="http://site.com/sites/sitename";
如果我去
site.com/controller/function/vars
然后
$config['base_url']="http://site.com/";
对于第二种情况,默认控制器可以完美加载。对于子站点情况不是/
我只得到404
该怎么办?
更新 2:
我有一个多文件夹设置。
当用户访问 www.site.com/sites/site_name
然后是应用程序的文件夹
/root_folder/usersites/site_name 已加载。
当用户只是 site.com/controller/function/var1/var2
默认应用程序文件夹是
/root_folder/应用程序已加载
当用户转到 sub1.site.com 应用程序文件夹时
/root_folder/domains/sub1_site_com 已加载
所以当我在地址栏中输入
http://site.com/sites/site_name
它应该就像没有 URI。并且应该加载默认控制器。
// Application folder loading code
$myApp = '';
if($_SERVER['SERVER_ADDR']=='127.0.0.1'){
$main_url='site.com';
}
else{
$main_url='site1.com';
}
//echo $main_url;
switch($_SERVER['HTTP_HOST'])
{
case $main_url;
$uri_string=$_SERVER['REQUEST_URI'];
$link_way=explode('/',$uri_string);
if(strlen($uri_string)>6 and $link_way[1]=='sites' ){
//print_r($link_way);
//var_dump($link_way);
//checking if the link goes to usersites and sitename is bigger and =5
if($link_way[1]=='sites' and strlen($link_way[2])>=5){
$myApp='sites/usersites/'.$link_way[2];
define('SITE_ALIAS','1|'.$link_way[2]);
}
elseif($link_way[1]=='sites' and strlen($link_way[2])<5){
exit('Username should be more than 4 chars');
}
}
else{
define('SITE_ALIAS','0|'.str_replace('.','_',$_SERVER['HTTP_HOST']));
$myApp = 'application';
}
break;
default:
$myApp = str_replace('.','_',$_SERVER['HTTP_HOST']);
$myApp=str_replace('www_','',$myApp);
define('SITE_ALIAS','2|'.$myApp);
$myApp='sites/domains/'.$myApp;
}
$application_folder = $myApp;