Search code examples
codeigniter-3virtualhostwampserver

Codeigniter base_url() config not changing


On a WAMP Virtual Host site I am using codeigniter's base_url to load content.

I have changed the file in the config (application/config/config.php)

$config['base_url'] = 'http://example.com/';

I have loaded the url helper in the autoload.php file. (application/config/autoload.php)

$autoload['helper'] = array('url');

And on my files I have the following to access the base url:

<img src="<?php echo base_url() ?>img/Logo.jpg" alt="Logo" height="150" width="150">

But the SRC address I am getting is (and the browser obviously doesn't find the resource):

http://[::1]/img/Logo.jpg

When I should be getting:

http://example.com/img/Logo.jpg

So, why isn't my codeigniter chaning the base_url()? Am I missing something?

EDIT: This is the configuration code for the virtual host:

<VirtualHost *:80>
  ServerName example.com
  ServerAlias example.com
  DocumentRoot "${INSTALL_DIR}/www/example/"
  <Directory "${INSTALL_DIR}/www/example/">
    AllowOverride All
    Options Indexes FollowSymLinks
    Require local
    Require ip 192.168.1
  </Directory>
</VirtualHost>

Solution

  • I found out the codeigniter configuration I had was tampered with. The code in system/core/Config.php

    It was overriden by someone else. Completely different problem. Replaced the file with the one codeigniter originally provides and it works.

    Your core config file should look like this:

    https://github.com/scotch-io/Github-API-Library-For-CodeIgniter/blob/master/system/core/Config.php