-4

Tried Removing Public folder folder url in laravel 9, by moving index.php from public to the root folder.

But i got an error when i removed index.php from public folder to the root folder

Nduk Elex
  • 1
  • 1
  • 2
    You shouldn't do it this way; it introduces serious security risks. Instead, you should properly configure your webserver to point at the public directory. – ceejayoz Apr 11 '23 at 10:48
  • 3
    "_... in Laravel 9_" fyi, it's been there forever – brombeer Apr 11 '23 at 10:53

1 Answers1

1

The index.php should stay in the public folder and you should point your webserver (Apache, Nginx, Caddy, etc.) to serve that file as the entry into the application.

If you were to use the root folder of your Laravel application as the document root (in your webserver) for your application, you expose all files in that folder to the webserver.

For example, you could reach your .env file at https://yourwebsite.com/.env. By keeping this in the public folder and using that folder as the document root, the rest of your application is "safe".