Codeigniter 4 Remove Public and Index.php From URL





Hi Guys,

In this blog, I will explain you how to codeigniter 4 remove public and index.php from url.If you want to remove public and index.php from URL in Codeigniter 4 framework. So this tutorial will help you.we would love to share with you, how to remove public and index.php from URLs in the new Codeigniter 4 frameworks.

The directory structure of the New Codeigniter 4 framework has been changed.

Step 1: Change in App.php File

The first step is to open the 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

In public/ directory, copy index.php and .htaccess to your root project directory.

Step 3: Change In index.php

In the root project directory, open index.php and edit the following line:

$pathsPath = FCPATH . '../app/Config/Paths.php';

change TO

$pathsPath = FCPATH . 'app/Config/Paths.php';

It will help you...