How to remove index.php from every url in codeigniter

In codeigniter by default, the index.php file will be included in every URLs, For example if you installed codeigniter locally like this “localhost/” or in a folder like this “localhost/codeigniter/”, if you want to go to any page, for ex: a page named demo, You should go to demo page like this “localhost/codeigniter/index.php/demo/”, otherwise you will get an error (“URL Not Found”).

You can easily remove this file by using a .htaccess file with some simple rules.

Copy this code and paste it into any text editor

and save the file with the name .htaccess, this file must be in your codeigniter root folder.

Now you can navigate your site’s structure without the index.php in front of every URL

Leave a Comment