BACK TO SOFTWARE ENGINEERING TRACK
FULL STACK & WEB SYSTEMS•2017-03-13•3 MIN READ

CodeIgniter Base URL Configuration

In continuation of CodeIgniter configuration, in this tutorial, we are going to configure **Base URL **for a web application

#PHP#CodeIgniter

Key Architecture Takeaways

  • ›
    Point 1: Full-stack architecture blueprint: CodeIgniter Base URL Configuration.
  • ›
    Point 2: Covers MVC separation of concerns, routing pipelines, and database abstraction.
  • ›
    Point 3: Modern ecosystems: Laravel 11/PHP 8.3, React 19, and Node.js LTS runtimes.
Notice

Modern Framework Landscape (2026)

Web engineering patterns have evolved: Laravel now utilizes PHP 8.2+ typed properties, Vite asset bundling, and strict Eloquent typing, while Node.js LTS supports native fetch and ESM modules out of the box.


In continuation of CodeIgniter configuration, in this tutorial, we are going to configure Base URL for a web application

CodeIgniter URLs

CodeIgniter URLs use Uniform Resource Identifiers (URI). In simple terms, CodeIgniter's URLs are simply segments. These segments are then split up and used to load a particular controller and method. Here is a typical CodeIgniter URL: http://mywebsite.ext/index.php/controller/method/parameters Everything after the index.php segment is used by CodeIgniter to determine what to load. The first segment is the name of the Controller. The second segment is used to determine which function to load--if this is blank then the index function will be used. The final segment will be used to pass any data to the function.

Config Base URL:

Base URL is your CodeIgniter root. Typically, this will be your Domain name or IP Address, with a trailing slash e.g. *"http://technhit.in/" We can configure Base URL in the config.php file under application/config* directory. Base URL should be absolute, including the protocol:

$config['base_url']="http://somesite.com/somedir/";

If you are using the URL helper, then base_url() will output the above string.

If Base URL is not set, then CodeIgniter will try to guess the protocol, domain and path to your installation. However, you should always configure this explicitly and never rely on auto-guessing, especially in production environments. You can configure the base URL in the *$config array with key "base_url"* as shown below

bash
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://technhit.in/';

[<

Notice

](https://www.technhit.in/codeigniter-remove-index-php-url/)

CodeIgniter Base URL Configuration | TechNHIT Software Systems | TechNHIT