简体   繁体   中英

Laravel 8 application return 404 Not Found

I have a Laravel 8 application that is properly running on a server. I have moved it to a different server but I am now getting a 404 Not Found on the new server. I have not changed anything on the new server so I believe it must an issue related to server. I am unable to diagnose the problem on the server. Details are some details about the app on the server:

File Permissions respects the following

chown -R apache.apache /var/www/LARAVEL_APP
chmod -R 755 /var/www/LARAVEL_APP
chmod -R 755 /var/www/LARAVEL_APP/storage

Routes and Cache have been cleared using the following commands:

php artisan route:clear
php artisan cache:clear
php artisan config:clear
php artisan cache:clear

.htaccess file in LARAVEL-APP/public directory:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>
   Options +FollowSymlinks
    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]
</IfModule>

When navigating to the root of the LARAVEL-APP, I can properly see the following screen. The problem occurs when I try to load the index.html located in LARAVEL-APP/public/index.php/admin/login在此处输入图片说明

Route List

The list is available when doing php artisan route:list | grep admin/login php artisan route:list | grep admin/login

|        | POST                                   | admin/login                                           | generated::LTvCw5lDDMDMdfPT                        | Brackets\AdminAuth\Http\Controllers\Auth\LoginController@login                                   | web                                                              |
|        | GET|HEAD                               | admin/login                                           | brackets/admin-auth::admin/login                   | Brackets\AdminAuth\Http\Controllers\Auth\LoginController@showLoginForm

404 Screen

Below is the 404 screen I am getting that seems to be from Laravel itself. 在此处输入图片说明

try this code in .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

I hope this work for you.

It seems like you have not enabled mod-rewrite , try this:

sudo a2enmod rewrite

and also make sure you this in your apache conf:

<Directory "/var/www/">
    # ...
    AllowOverride All
    Require all granted
</Directory>

also restart apache after:

sudo service apache2 restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM