Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

need_a_hat's avatar

Getting Laravel 404 page every route

I have a working app on my dev machine, and just moved it to a production server with the help of Laravel Forge. Now being served on Digital Ocean. However in production all I can get is the Laravel 404 page no matter what URL I try. I checked with Forge support and they said it's nothing to do with Forge (after all it is pulling up a Laravel page, albeit the 404 page) I can do artisan and tinker just fine. I've created a new key, composer updates, and such. I'd like to provide more info, but I don't know what info is relevant to share.

0 likes
10 replies
need_a_hat's avatar

I've used just default .htaccess file below, but also tried different variations as described in Laravel docs. None of it made a difference.

< IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
need_a_hat's avatar

$sudo a2enmod rewrite returns "Module rewrite already enabled" Although I think my Ubuntu is actually running nginx

jlrdw's avatar

Did you view some of Digital Oceans how to articles on setup as well?

1 like
need_a_hat's avatar

And worked through these commands, which don't seem to be causing a problem $php artisan key:generate $php artisan config:cache $npm install and $npm run prod $composer install and update $composer dump-autoload

jlrdw's avatar

@need_a_hat but you are using apache, right? Or is server Nginx? Read the deployment chapter in the documentation.

1 like
need_a_hat's avatar

@jlrdw Actually I believe nginx. I checked status and it is running, whereas apache is not. And I now checked the nginx logs. all looks ok there.

siangboon's avatar

may also check the laravel log perhaps write a simple html file at the public to ensure the document root landed at public folder...

1 like
need_a_hat's avatar

@siangboon thanks. yeah i'm able to access .json files i put in the /public folder. no problem there.

need_a_hat's avatar

Problem solved: The steps I ended up taking with guidance were to check the APP_URL and set to http=[mysite.com] and then in Forge > Commands > php artisan cache:clear; php artisan config:clear. And that did it.

Please or to participate in this conversation.