Laravel returning 404 even when route exists

I had encountered an issue where all the pages I had created on Laravel returns 404 error – page not found even when the route exists except for the homepage. The fix is to add AllowOverride All in your Apache configuration file.

Here are the steps, my server is Ubuntu 18.04 LTS

1. go to Apache configuration files folder.
cd /etc/apache2/sites-available/

2. Edit the configuration file via vim, 000-default.conf if you are using http://, default-ssl.conf if you are using https://
sudo vim default-ssl.conf

3. Type i to modify the file, add these block after your DocumentRoot declaration.

<Directory /var/www/html/public>
Options +FollowSymlinks
AllowOverride All
Require all granted

/var/www/html/public is the root of your Laravel application, modify if needed.

4. Hit the ESC button the type :wq to save the changes

5. Restart Apache.
sudo service apache2 restart