For any queries you can reach us at infovistarindia@gmail.com / WhatsApp us: +919158876092

Remove index.php from URL in CodeIgniter 4

How to remove index.php from URL in Codeigniter 4

  1. 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';
  2. 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.

  3. 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';