1

I am using Codeigniter 3.1.0 which latest now. I have set base_url in config.php as

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

When I print base_url(). It is showing Server IP instead what I set.

http://173.x.xx.21/kp_clients/

Now what I am doing wrong here. Any idea?

I have autoloaded all required library

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

and its working fine in local but stoppped working in live server

NOTE: base_url() function not working in codeigniter I have checked this. This is because not load url helper. I have clearly mentioned in my question that I have autoloaded the helper. Still its showing IP instead what I am setting

Community
  • 1
  • 1
Rejoanul Alam
  • 5,435
  • 3
  • 39
  • 68

2 Answers2

1

Before using base_url() function load 'url' helper first in application/config/autoload.php

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

Or, manually using $this->load->helper('url'); Now echo base_url(); gives the url what have loaded in $config['base_url'] config parameter.

lnepal
  • 549
  • 8
  • 20
0

I got the issue. It was a old project & there were a directory name production in config folder. I was forgot about this directory & there were not set the base_url this is why its auto detecting server IP.

In fact my config.php was not active here. Rather production/config.php was working there. Now solved

Rejoanul Alam
  • 5,435
  • 3
  • 39
  • 68