How to change public directory in Laravel 11

Published on April 29, 2024. Last updated on January 22, 2025.
How to change public directory in Laravel 11

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.