Lumen Routes 显示 404,root route 除外

Lumen Routes shows 404 except root route

我是第一次使用流明。我将流明文件放在文件夹 Test 中,并将文件夹保存在服务器中的 /var/www/html 路径中。我的 PHP 版本是 7.4.3

我有以下路线:

$router->get('/key', function() {
return str_random(32);
});

$router->get('/', function () use ($router) {
return $router->app->version();
});

下面是我的 htaccess:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

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]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

但每当我尝试访问 http://xx.xxx.xxx.xxx/Test/public/key 时,它都会显示

The requested URL was not found on this server.

但是如果我尝试访问 http://xx.xxx.xxx.xxx/Test/public/ 它 returns 我

流明 (5.7.8)(Laravel 组件 5.7.*)

我怎样才能使所有其他路线也有效?

似乎重写规则被禁用了

sudo a2enmod rewrite

sudo service apache2 restart

我在 /etc/apache2/apache2.conf 文件中搜索了 <目录 /var/www/ > 并更改了以下内容

AllowOverride None 

AllowOverride All

重新启动了apache。它解决了我的问题。