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.

One Reply to “How to remove / hide index.php from url in CodeIgniter – .Htaccess Trick”

  1. Hi sir, I’m a big follower of your page. can you please provide me an example of Hiding URL in address bar using Jquery. Thank you.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.