After learning CodeIgniter routing the next step is CodeIgniter base URL configuration. The base URL will indicate the name of the domain on which your application is deployed.

In our case, the base URL is “”. In the config folder under the application you can configure the base URL of your application.

There you will found “config.php” file which allows you to configure the base URL.

If you will not configure the base URL then CodeIgniter will automatically predict the domain name and protocol. But it is not a good practice for the production version of the application. You must have to configure the base URL manually.

You can easily configure the best way around within the “$config” array as we have done in the following code.

$config['base_url'] = '';

In this way, your root URL will be the above. Whenever you will need to concatenate what utilize the base URL you will access that as we have done in the following code.

<?php echo base_url();?>

For an example, we have custom style-sheet of the application and we need to bind that with the layout file. Following is the static path of the style-sheet.

<link rel="stylesheet" type="text/css" href="">

Now we will convert the static path of custom style-sheet into dynamic path with the help of base URL.

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>/css/stylesheet.css">

Now you may think what is the advantage of making dynamic URL with the help of base URL. The biggest advantage to make dynamic URL is that you can deploy the same code for multiple domains and you just need to configure the base URL once to implement in the whole application.

In this way, you not only save your time but also you will improve the efficiency of your application. This is the most practicing technique which CodeIgniter developers are used during the development of applications.