我是第一次使用 Lumen。我将流明文件放在文件夹 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/它返回我
Lumen (5.7.8)(Laravel 组件 5.7.*)
我怎样才能使所有其他路由也能正常工作?
最佳答案
似乎重写规则被禁用了
sudo a2enmod rewrite
sudo service apache2 restart
关于php - Lumen Routes 显示 404,root route 除外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60394048/