In this post, we will show you how to remove “
public” from URL in CodeIgniter 4 (CI4) framework.
Here are some CI4 URL examples containing “
http://localhost/MyCodeIgniter4App/public/ http://localhost/MyCodeIgniter4App/public/register https://yourdomain.com/public/ https://yourdomain.com/public/register
You want to remove “public” from the URL, i.e. it will become:
http://localhost/MyCodeIgniter4App/ http://localhost/MyCodeIgniter4App/register https://yourdomain.com https://yourdomain.com/register
To do this, let’s follow the following 2 steps:
Step 1: In
public/ directory, copy
.htaccess to your root project directory.
Step 2: In the root project directory, open
index.php and edit the following line:
$pathsPath = FCPATH . '../app/Config/Paths.php';
$pathsPath = FCPATH . 'app/Config/Paths.php';