How to remove / hide index.php from url in CodeIgniter – .Htaccess Trick

Here one more quick post for beginner CodeIgniter developer for removing index.php from the URL, In few days back I have compiled some CodeIgniter Interview questions and answers for beginner, And this is another quick post for hiding index.php from URL and making your application URL’s SEO friendly by using .htaccess trick. In CodeIgniter By default, the index.php file will be included with the URL. But you can easily remove the index.php by following .htaccess trick.

First make sure that mod_rewrite is On in your Apache Web Server other wise .htaccess will not work. After that Create .htaccess file in the root directory of your application and add the following code in .htaccess file.


RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ INDEX.php/$1 [L]

Before .htaccess rule CodeIgniter URL’s look like

After using above .htaccess rules CodeIgniter URL’s look like.