How to remove public from url in codeigniter 4

Deepak Tailor Image
Deepak Tailor - Sep 20 2020
How to remove public from   url in codeigniter 4

Roots are designed to search pages in codeigniter framework. These routes are segment based. Like As:

http://www.yourdomain.com/Samsung/mobile/sumsung-galaxy-a30-mobile

http://www.yourdomain.com // domain name

sumsung // first segment or class name or controller name

mobile // second segment or function name

sumsung-galaxy-a30-mobile // third segment or argument

Index.php by URL is the default include in the URL provided by codeigniter. It can also be removed from the URL.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Save this code by creating an .htaccess file in your root folder.

Remove public folder

index.php file and. Cut the .htaccess file from the public folder and paste it into the root file. Then change something in the index.php file like:

$pathsPath = realpath(FCPATH . '../app/Config/Paths.php');
// to
$pathsPath = realpath(FCPATH . './app/Config/Paths.php');
Deepak Tailor Image
Deepak Tailor

My name is Deepak tailor as a fullstack developer. I have been in the IT industry for the last 5 years. For professional and customize web development, you can send inquiry on our email.
----
You can contact him at support@fulstackdev.com