Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove public/index.php/ from url in Codeigniter 4

I want normal URL like www.sample.com/controller not www.sample.com/public/index.php/controller.

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

My .htaccess file

like image 363
caveboy Avatar asked Jan 22 '18 06:01

caveboy


1 Answers

Just do

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

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

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

to

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

like image 158
manish Avatar answered Sep 22 '22 21:09

manish