To run Codeigniter framework in a sub folder or sub directory of your web root and auto switch the configuration between local environment and live environment, we will need to edit the config.php file (which is located at Codeigniter root/application/config folder) as below:
/* |-------------------------------------------------------------------------- | Base Site URL |-------------------------------------------------------------------------- | | URL to your CodeIgniter root. Typically this will be your base URL, | WITH a trailing slash: | | http://example.com/ | | If this is not set then CodeIgniter will guess the protocol, domain and | path to your installation. | */ if($_SERVER["SERVER_ADDR"] == "127.0.0.1") { $config['base_url'] = ''; } else { $config['base_url'] = 'http://yourdomain.com/path-to-codeigniter/'; } |