How to remove index.php from URL in Codeigniter 4
-
Update in the App.php File
We need to change baseURL, indexPage and uriProtocol in the /app/Config/App.php file. You can refer the below changes.
Then After public $baseURL = 'http://localhost:8080';
public $baseURL = 'http://localhost/your_project/';
public $indexPage = 'index.php';
public $indexPage = '';
public $uriProtocol = 'REQUEST_URI';
public $uriProtocol = 'PATH_INFO';
-
Copy index.php and .htaccess files
Copy the index.php and .htaccess files file from the public directory and paste on root your project directory.
-
Update In the index.php
Open index.php file and change the pathsPath.
Then After $pathsPath = FCPATH . '../app/Config/Paths.php';
$pathsPath = FCPATH . 'app/Config/Paths.php';