CodeIgniter Tutorial - Create a Controller

1. Create a  new file at application/controllers.

2. Insert the following code in your controller. Make sure that you extend the CI_Controller.


CodeIgniter Tutorial - Configure Database Settings

1. Go to App/Config/Database

2. Define your preferred Settings (e.g. Database name, host name, username, and so on.


3. Load the Database in following

     a. Via Autoload.php


    b. Inside the constructor


    c. Inside your function



CodeIgniter Tutorial - How to define the base URL

Open the application/config/config.php




Change the configuration of $config['base_url'] = 'http://localhost/projec-name';

CodeIgniter Tutorial - How to Remove index.php

CodeIgniter Tutorial - How to Remove index.php
Copy the following code and create a .htaccess file. Save the file inside your project folder.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /replace this with your base url
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css)
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>



CodeIgniter Tutorial - Download and Install CodeIgniter




  • Unzip the package.
  • Upload the unzipped CodeIgniter files to your server. (e.g. htdocs folder)

  • Check your base URL