• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove public/index.php/ from url

Hello Guys !

I ran into this problem too. My point is that I´m running my website on a SHARED HOSTING and I don´t want to mess around...

I just solved this by adding a .htaccess file in root directory:

DirectoryIndex /public/index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./public/index.php/$1 [L,QSA]

It's very simple:

- keep the original .htaccess from the public folder

- copy .htacccess and index.php from public folder to the root of your project;

- edit the index.php and change the line below...

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


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

That's it!

Based on your issue. I had the same problem look. I created two .htaccess file one at the public folder and the other at the root directory but no success so.
This is how I solved my own problem =>
I move the default .htaccess and the index.php files in the public directory to the root directory then I edit the index file to point to the app directory just like the code below
PHP Code:
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath FCPATH '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder 
to this below
PHP Code:
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath FCPATH './app/Config/Paths.php';
// ^^^ Change this if you move your application folder 
I hope this will help you and others who are also facing the same issue
Visit Chivins.Com For Free Tutorial on Codeigniter

(01-22-2018, 12:38 AM)ciadmin Wrote: https://bcit-ci.github.io/CodeIgniter4/g...x-php-file

If xxx/controller doesn't work, but xxx/index.php/controller does, then your htaccess is not working. Could be rewrite_module not loaded, or wrong permissions.
If xxx/controller doesn't work, but xxx/public/controller does, then your document root is set incorrectly inside apache.

If you have to resort to xxx/public/anything, then your document root is set incorrectly!
Hi, where do you set the document root?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.