Mauricio Webtailor
Mauricio Webtailor

Reputation: 11

one codeigniter controller named site needs to handle multiple domains

Got a controller in codeigniter who handles different sub sites.

Now we decided to register domain names for these sub sites.

so what we need:

http://www.subsite1.com  -> default controller should be site/index/1

without the site/index/1 in the URI.

http://www.subsite2.com  -> default controller should be site/index/2

without the site/index/2 in the URI.

I fiddled and tried to play with routes.php but getting nowhere.. Can somebody point me in the right direction?

Upvotes: 1

Views: 492

Answers (1)

Rooster
Rooster

Reputation: 10077

in your routes.php file you need to set this:

$route['default_controller'] = ($_SERVER['SERVER_NAME'] == 'http://www.subsite1.com' ? "site/index/1" : "site/index/2");

and if your trying to force it somewhere when some weird url is types in:

$route['404_override'] = ($_SERVER['SERVER_NAME'] == 'http://www.subsite1.com' ? "site/index/1" : "site/index/2");

and for the second one just switch it to 2

Upvotes: 1

Related Questions