Question: Is there any way to set my `base_url()` from my controller's ? 

OR Can I set my `base_url` `Dynamic` ?

How can I achieved this ?

Answer: 
After Searching i found the solution .
yes we can change the base\_url from our controller as

```
$this->config->set_item('base_url','http://example.com/xyz') ;

```

Ref: [User Guide](http://ellislab.com/codeigniter/user-guide/libraries/config.html)

May this answer should help some one .
OK, so this was fun, but it might not work right and/or break all kinds of other stuff. But, if you make these changes in the relevant files, you can have multiple base url config settings in the config file like so:

```
$config['base_url']['default']  = 'http://firstbase.xyz';
$config['base_url']['otherbase']    = 'http://secondbase.xyz';

```

which can be called like `base_url('','default');//produces <http://firstbase.xyz>`.

It seems much easier/better to use `$this->config->set_item('base_url','http://abc.com/xyz') ;` as you found in the docs.

---

system/helpers/url\_helper.php : line ~63

```
if ( ! function_exists('base_url'))
{
    function base_url($uri = '',$index='')
    {
        $CI =& get_instance();
        return $CI->config->base_url($uri,$index);
    }
}

```

---

system/core/Config.php

> 
> line ~66
> 
> 
> 

```
$this->set_item('base_url', $index);

```

> 
> line ~175
> 
> 
> 

```
function item($item, $index = '')
{
    if ($index == '')
    {
        if ( ! isset($this->config[$item]))
        {
            return FALSE;
        }

        $pref = $this->config[$item];
    }
    else
    {
        if ( ! isset($this->config[$index]))
        {
            return FALSE;
        }

        if ( ! isset($this->config[$index][$item]))
        {
            return FALSE;
        }

        $pref = $this->config[$index][$item];
    }

    return $pref;
}

```

> 
> line ~214
> 
> 
> 

```
function slash_item($item,$index)
{
    if ( ! isset($this->config[$item][$index]))
    {
        return FALSE;
    }
    if( trim($this->config[$item][$index]) == '')
    {
        return '';
    }
    return rtrim($this->config[$item][$index], '/').'/';
}

```

> 
> line ~265
> 
> 
> 

```
function base_url($uri = '',$index='')
{
    return $this->slash_item('base_url',$index).ltrim($this->_uri_string($uri),'/');
}

```

> 
> line ~332
> 
> 
> 

```
function set_item($item, $value, $index)
{
    $this->config[$item][$index] = $value;
}

```