Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To set the public folder as the root in CodeIgniter's .htaccess file, follow these steps:

  1. Move all the contents of your application folder to the public folder, except the index.php file and the .htaccess file.

  2. Open the .htaccess file in the application folder and delete all the content.

  3. Open the .htaccess file in the public folder and add the following code:

RewriteEngine On
RewriteRule ^(.*)$ index.php/$1 [L]

This code will redirect all requests to the index.php file in the public folder.

  1. Change the $systempath and $applicationfolder paths in the index.php file to use the correct paths to the system and application folders.
$application_folder = '../application';
$system_path = '../system';
  1. Save the changes and upload the files to your web server.

Now, when you access your website, the public folder will be the root directory, and CodeIgniter will handle all requests through the index.php file in the public folder.