In this tutorial,I will learn you how to remove public and index.php from url in codeigniter 4.you can easy and simply remove public and index.php from url in codeigniter 4.
we will learn how to remove index.php from URL in Codeigniter 4. why are you remove index.php from URL? because when users using create SEO friendly, user readability and easy to understand for the user.
Step 1: Update in the App.php File
The first step is to open the app.app file. And the changes mentioned below. You have to do this in your App.php file.
So go to project_name/app/Config/App.php and change mention below:
public $baseURL = 'http://localhost:8080';
public $baseURL = 'http://localhost/your_project_name/';
And the second change in the app.php file:
public $uriProtocol = 'REQUEST_URI';
public $uriProtocol = 'PATH_INFO';
Step 2: Copy index.php and .htaccess files
The second step Copy the “index.php” and “.htaccess” files file in the public directory and paste on root your project directory.
Step 3: Update In the index.php
Finally, after move successfully files on the root directory. The open “index.php” file and change the pathsPath.
$pathsPath = FCPATH . '../app/Config/Paths.php';
$pathsPath = FCPATH . 'app/Config/Paths.php';
It will help you...