How to make public folder as root in Laravel?

Do not modify any Laravel files. Instead configure your web server (Apache or Nginx) to point to the Laravel project’s public directory.

For Apache you can use these directives:

DocumentRoot "/path_to_laravel_project/public"
<Directory "/path_to_laravel_project/public">

For nginx, you should change this line:

root /path_to_laravel_project/public;

Having your document root as /path_to_laravel_project/ alone will create serious security risks, potentially opening your entire app configuration to the internet.

Leave a Comment