1

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.

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.