S
S
sasha_jarvi2020-09-04 23:08:20
Apache HTTP Server
sasha_jarvi, 2020-09-04 23:08:20

How to fix 404 Not Found error in Laravel under Ubuntu 20.04?

I started making an application on Laravel, put it in /var/www/app.test, added a new route to api.php:

<?php

use App\Listing;
use Illuminate\Support\Facades\Route;

Route::get('listing/{listing}', function (Listing $listing) {
    return $listing->toJson();
});


I tried to test this route, but instead of an entry from the table, a 404 Not Found error appears. I thought that this might be related to .htaccess, I changed the apache and site configs as follows:

1) I /etc/apache2/apache.confadded the following lines:
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


2) site config looks like this:
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName app.test
    ServerAlias www.app.test
    DocumentRoot /var/www/app.test

    ErrorLog ${APACHE_LOG_DIR}/app_error.log
    CustomLog ${APACHE_LOG_DIR}/app_access.log combined
</VirtualHost>

<Directory /var/www/app.test>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


3) the file /etc/apache2/sites-available/000-default.conflooks like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


mod_rewriteincluded. But after the above changes and restarting apache, the error did not go away. How to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question