Home » CodeIgniter » CodeIgniter Routing Issue Handling

CodeIgniter Routing Issue Handling

Codeigniter, A very much familiar name for the PHP developers. But starting with this MVC sometimes lead to a very common yet simple problem. After running this framework you can usually see an index.php in the URL. Like: http://somedomain.com/index.php/slug.That’s very much annoying. I checked the routes.php file and it did not help me. But later I found that it is a very much easy solution with some configuration settings and it will be fixed for both local and live server.

First of all, you have to open your config.php file in the application/config directory and change the lines like below.


//for https you can use https://
$root = "http://".$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root; // assign the $root value

$config['index_page'] = ''; // make it empty if not

$config['uri_protocol']	= 'REQUEST_URI'; // make it like this

You are almost done. But you have to do some more task. Create a .htaccess file at the very root of your directory, Or if there is any then replace the code of the files like below and reload the page.

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

I hope your problem will be solved by following this instruction. Thanks, guys and hope this post will help you a little bit.


I picked PHP and JavaScript as a career start-up and developed a lot of applications using these. Like Management Application, Web Scrapping, Web API, E-Commerce Solutions, Finance Application etc. Outside of my professional life, I also do projects and code for reputation and my personal portfolio.

Leave a Reply

Your email address will not be published. Required fields are marked *