php - Lumen Routes 显示 404,root route 除外

标签 php laravel .htaccess lumen

我是第一次使用 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/

相关文章:

php - 相似文本 php mysql

php - 返回 PHP 数组名

php - Apache Mod_Rewrite 不断重定向

php - PHP 和 .htaccess 重定向之间的区别

php - .htaccess mod 重写目录索引

javascript - 一次输入两种形式

php - 自动重复发布项目直至满足要求

php - Laravel 9.x 目标类在登录应用程序时不存在错误

php - Laravel/Carbon 中的多时区

php - 错误 404,即使路由存在 - AWS,Laravel