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

Atef95's avatar

404 routes problem laravel

Hey guys I'm trying to deploy my app in production but I'm facing 404 not found error on laravel routes..

I followed some tutorials and did the following

sudo a2enmod rewrite
sudo service apache2 restart

edited /etc/apache2/sites-available/my-file.conf

    DocumentRoot /var/www/html/
        <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>


edited /etc/apache2/sites-available/apache2.conf

from

    DocumentRoot /var/www/html/
        <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        </Directory>


to

    DocumentRoot /var/www/html/
        <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        </Directory>


it get fixed but when I access again for a couple of times i get back the same error.. couldn't know why this happening..

0 likes
4 replies
skauk's avatar

You need to configure your webserver to route all requests to public/index.php. Otherwise routing will not work. There are instructions available on how to do that in Laravel documentation.

Atef95's avatar

I've been googling from the morning and all answers say it's related to apache !

and I couldn't figure out where the problem is coming from .. this is really crazy :(

geowrgetudor's avatar
DocumentRoot /var/www/html/public
     
<Directory /var/www/html/public/>
Atef95's avatar

I just added /index.php at the end of url and everything worked...

Please or to participate in this conversation.