我有一个在服务器上正常运行的Laravel 8应用程序。我已经将它移到了另一台服务器上,但现在在新服务器上没有找到404。我没有改变新服务器上的任何东西,所以我相信它必须是一个与服务器相关的问题。我无法诊断服务器上的问题。详细信息是关于服务器上的应用程序的一些细节:
文件权限尊重以下
chown -R apache.apache /var/www/LARAVEL_APP
chmod -R 755 /var/www/LARAVEL_APP
chmod -R 755 /var/www/LARAVEL_APP/storage使用以下命令清除了路由和缓存:
php artisan route:clear
php artisan cache:clear
php artisan config:clear
php artisan cache:clearLARAVEL/公共目录中的.htaccess文件:
<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>当导航到LARAVEL的根目录时,我可以正确地看到下面的屏幕。当我试图加载位于index.html中的LARAVEL-APP/public/index.php/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@showLoginForm404屏幕
下面是我得到的404屏幕,它似乎是来自Laravel本身。

发布于 2021-07-16 08:25:33
在.htaccess文件中尝试这段代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>我希望这对你有用。
发布于 2021-07-16 09:09:35
似乎您还没有启用mod-rewrite,请尝试如下:
sudo a2enmod rewrite并确保您在apache conf中这样做:
<Directory "/var/www/">
# ...
AllowOverride All
Require all granted
</Directory>还请在以下位置重新启动apache:
sudo service apache2 restarthttps://stackoverflow.com/questions/68405562
复制相似问题