How to remove the index.php in codeigniter in its versions 3 and 4 a step by step guide
Remove index.php in codeigniter 4
First we will see how to remove the index.php in codeigniter 4, which is the latest updated version of the framework
We go to the following route app/config/App.php , in this file we will look for the property called indexPage and simply remove the value , it would be as follows
public $indexPage = '';
We can also carry out the same process by declaring the app.indexPage property in the .env file and we would have the same result as in the previous case, first we have to put the app name before it followed by the period
Remove index.php in codeigniter 3
In the second case we will see how to remove the index.php in codeigniter 3, for this example we need to go to the following route application/config/config.php , now we will look for the variable called index_page and remove the value , it would be as follows form
$config['index_page'] = '';
We still need to take another step to be able to work with friendly urls in codeigniter , we will create a file called .htaccess in the root of the project and we will add the following rules associated with apache server, in this example we also give permissions to directories to be able to load images, recognize styles among other things
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|assets|js|theme|uploads)
RewriteRule ^(.*)$ index.php/$1 [L]