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

Chris_'s avatar

Routes on Apache server not found.

Hello,

We deployed a Laravel application on a development server

I have a 404 of Laravel on all my routes, root included.

I did composer dump-autoload, php artisan clear-compiled, php artisan optimize, restart apache

for the config, we have a .htaccess file with :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !/public
RewriteRule ^(.*)$ public/ [L]
</IfModule>

and in the .env we set APP_ENV=staging and APP_URL="..."

Apache conf :

<Directory "...">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

The application works fine on my PC with php artisan serve

0 likes
16 replies
Snapey's avatar

show the rest of your .conf file

is it an apache 404 or laravel 404?

Chris_'s avatar

ServerRoot "/etc/httpd"

Listen 8081

Include conf.modules.d/*.conf

User apache Group apache

ServerAdmin root@localhost

AllowOverride none Require all denied

DocumentRoot "/var/srv_app/apache/html"

<Directory "/var/srv_app/apache/html">

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Require all granted

<Directory "/var/srv_app/apache/html/app/Test"> AllowOverride All Options FollowSymLinks

Require all granted </Directory>

DirectoryIndex index.html index.php

<Files ".ht*"> Require all denied </Files>

ErrorLog "logs/error_log"

LogLevel warn

LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined LogFormat "%h %l %u %t "%r" %>s %b" common

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

CustomLog "logs/access_log" combined </IfModule>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin"> AllowOverride None Options None Require all granted </Directory>

TypesConfig /etc/mime.types

AddType application/x-compress .Z AddType application/x-gzip .gz .tgz

AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule>

AddDefaultCharset UTF-8

MIMEMagicFile conf/magic </IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

Chris_'s avatar

I just removed the comments and changed the private paths.

Randy_Johnson's avatar

@Chris_ The best bet is to contact the server admins. There could be a number of things that can go wrong on their side, and this is usually the case.

How did you put the files on the hosting?

PS. If it says Laravel 404, I don't think it has anything to do with Apache. Are you sure that nothing got deleted in the files, when transferring.

Chris_'s avatar

@Randy_Johnson

Thank you,

The application was copied on dev from local by SFTP, including the vendors because we don't have permission to do composer install/update. I think that could be the source of the problem.

Also, there is no vhost, i was told that this would not be necessary on this server.

1 like
MohcinBN's avatar

I suggest you try php artisan route:clear. This resets the route cache.

Snapey's avatar

Your document root should be the public folder.

You are asking for trouble if you have followed sketchy tutorials that advise editing the index.php or moving stuff around.

so I would expect to see

DocumentRoot "/var/srv_app/apache/html/public"
Chris_'s avatar

@Snapey

Thank you, the server admin is not available today.

We'll try that tomorrow.

Chris_'s avatar

@Snapey

Hello,

It didn't work.

We have advanced, but we have error 500 on all routes with

InvalidArgumentException View [Test] not found.

and

Illuminate\View\FileViewFinder::findInPaths vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php:137

All routes works on local with php artisan serve command

Chris_'s avatar

The routes works if we don't try to access the database. and we have access to the database with php artisan tinker or command line

Please or to participate in this conversation.