Codeigniter: Base_url doesn't seem to be working Codeigniter: Base_url doesn't seem to be working codeigniter codeigniter

Codeigniter: Base_url doesn't seem to be working


I am on the grid as well. After re-reading your question and doing a little testing (it works for me), I think what's happening is you forgot to load the url helper.

If you want the sites base url available to you to use in the application via base_url(), you need to load the url helper first. Either via config/autoload.php or load it manually in your controller.

Otherwise you could use config/constants.php to define constant variables:

define('BASE_URL', 'http://site.com');define('BASE_PATH', '/path/to/CI/folder');


Just a quick note on base_url - might be a good idea to dynamically set this variable, as it will allow your site to support multiple domains.

(i.e. $config['base_url']    = ‘http://’.$_SERVER['HTTP_HOST'])

http://thecodeabode.blogspot.com/2010/10/codeigniter-supporting-multiple-domains.html expands a bit on this by giving scripts that take into consideration protocol and port.