I have a multi-user codeigniter installation where I have code that I can serve on sites with such links
site.com/sites/sitename/controller/function/vars site.com/controller/function/vars/
subdom.site.com/controller/function/vars
the problem is that when routing
$route['sites/([^/]+)/(.*)'] = '$2';
$route['default_controller'] = "content";
I get working links like
site.com/sites/sitename/controller/function/vars site.com/controller/function/vars
In theory, when I go to
www.site.com/sites/sitename/
the controller does not boot by default.
I made config.php so that regarding the link structure when I visit the link
site.com/sites/sitename/controller/function/vars
then
$config['base_url']="http://site.com/sites/sitename";
if i go to
site.com/controller/function/vars
then
$ configuration ['base_url'] = "http://site.com/";
for the second case, the controller loads fine by default. For the case of a sub-site, not /
I get only 404
What to do?
UPDATE 2:
I have a multi-threaded installation.
When a user goes to www.site.com/sites/site_name
then application folder
Loading/ root_folder / usersites / site_name.
When a user is sent only to the site .com / controller / function / var1 / var2
default application folder which
/ root_folder / application uploaded
when the user goes to the sub1.site.com application folder
/ root_folder / domains / sub1_site_com uploaded
So, when I enter the address bar
http://site.com/sites/site_name
it should be like a URI. and should load the default controller.
$myApp = '';
if($_SERVER['SERVER_ADDR']=='127.0.0.1'){
$main_url='site.com';
}
else{
$main_url='site1.com';
}
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' ){
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;