How to change public directory in Laravel 11

Learn how to change public directory in Laravel.

How to change public directory in Laravel 11

April 29, 2024

If you find yourself in a situation where you need to change the public directory to public_html due to limitations of shared hosting environments.

To achieve this in Laravel 11, open your bootstrap/app.php file and add the following code:

// ....
->create()
->usePublicPath(dirname(__DIR__).'/public_html');

 

With this change, your application will now use public_html as its public directory.