Reputation: 381
I would like to implement the following url structure over the codeigniter
http://client.xyz.com/division/controller/controller_fuction
Will you please let me know how can i change the route file to meet my requirement. Thanks.
Comment -
I would like to setup client wise sepearate database and 'division' may be like division1, division2. Depend on the url setting and session would be loaded.
Upvotes: 1
Views: 1876
Reputation: 19882
You can create MY_Controller which will extend CI_Controller.
Every other controller will extend MY_Controller.
Then in MY_Controller you can use this in constructor.
$controller = $this->uri->segment(1);
$controller_function = $this->uri->segment(2);
Here you can define $devisions or get it from config.
$division1 = array('controller1','controller2','controller3');
$division2 = array('controller4','controller5','controller6');
$division3 = array('controller7','controller8','controller9');
if(in_array($controller,$division1)){
//do blah blah
}else if(in_array($controller,$division2)){
//do other blah blah
}else{
//do last and final blah blah
}
Upvotes: 0
Reputation: 4142
set in the config file
$config['index_page'] = '';
then apply htacess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|img|js)
RewriteRule ^(.*)$ ./index.php/$1 [L]
this way you can do like http://client.xyz.com/division/controller/controller_fuction
OR you can use Routing
Upvotes: 1
Reputation: 4430
You need to create your own route class, CI lets us to replace or extend it's core functionality. Just create e.g
class MY_Router extends CI_Router
{
//so on ..
}
Then save it in application/core
folder, then CI will using your Class instead of default.
look ? http://ellislab.com/codeigniter/user-guide/general/core_classes.html
Upvotes: 0