Ask Your Question
0

How can the public folder be set as the root in Codeigniter's .htaccess file?

asked 2023-06-02 21:28:59 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-02 21:33:02 +0000

lalupa gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-02 21:28:59 +0000

Seen: 16 times

Last updated: Jun 02 '23