Remove index.php from url in codeigniter

While you install fresh Codeigniter your URL is some thing like this:

But this URL structure is not so much charming and is also not much SEO friendly. So we would like to change above URL to something life this:

To modify the URL you need to enable mod_rewrite module first, since it’s initially disabled in apache configuration file. Open httpd.conf and search for “mod_rewrite”. If you are a WAMP user like me than to find httpd.conf in your Taskbar click WAMP icon -> Apache->httpd.conf. You will find a line with following text.

#LoadModule rewrite_module modules/ #AddModule mod_rewrite.c

Uncomment the lines (remove the trailing #) like this:

LoadModule rewrite_module modules/ #AddModule mod_rewrite.c

Than you need to restart the WAMP or whatever server you are using.

Now next step to to create a .htaccess file with following code.

Now if you remove index.php from you URL then it would perfectly work. In some of the server we will find error showing “No input file specified“. Then we need to just add “?” after index.php and it will solve problem.

I hope this small post would help you some how. Happy Coding.