Menu

1 / 2

Laravel returns 404 on every route after deployment. Here is the fix.

DEV Community: laravel·Mehedi Mansur Rafi·9 days ago
#gKu67Hih
#devtolaravel#devto#dev#server#file
Reading 0:00
15s threshold

Part 3 of Laravel in Production .

You uploaded your Laravel project, the home page opens, and every other page shows 404. I have seen this exact fault on shared hosting, on a cloud server, and on my own laptop server. In most cases the code is fine. The server is looking in the wrong folder. Laravel expects requests to reach public/index.php. If the web root points at the project folder instead, the home page can load by luck while the rest fail, or the whole site breaks in a way that looks like a routing bug. I will also show the two log lines that tell you the server hit the wrong folder, so you can prove the cause. This tutorial walks through the check I run first, how to set the document root on cPanel and on a plain Apache or Nginx server, and how to confirm the fix in a private browser window before you touch any route file.

The 2 minute check

Do not edit any code yet.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.