This is like for language code in url.
With my solution you can put any segment in your uri and hide it to CI.
http://site.com/page.html will be equal to http://site.com/canada/page.html and vice versa.
set_country_uri.php
//App location
$ci_directory = '/ci/';
//countries
$countries = array('canada','france');
//default country
$country = 'canada';
foreach( $countries as $c )
{
if(strpos($_SERVER['REQUEST_URI'], $ci_directory.$c)===0)
{
//Store country founded
$country = $c;
//Delete country from URI, codeigniter will don't know is exists !
$_SERVER['REQUEST_URI'] = substr_replace($_SERVER['REQUEST_URI'], '', strpos($_SERVER['REQUEST_URI'], '/'.$c)+1, strlen($c)+1);
break;
}
}
//Add the country in URI, for site_url() function
$assign_to_config['index_page'] = $country."/";
//store country founded, to be able access it in your app
define('COUNTRY', $country);
index.php
<?php
require('set_country_uri.php');
//ci code ...
So in your CI code use COUNTRY
constant to know wich is used. And make your code like routing without take in consideration the country in the uri.