Slim 3.8 框架无法路由
Slim 3.8 framework failing to route
我已经使用 slim 一段时间了,今天我更新到 3.8 并且开箱即用,我发现了一些东西
$app->get('/', function ($request, $response) {
return 'Slim working';
});
$app->get('/hello', function ($request, $response) {
return 'Slim hello also working';
});
第一个方法调用有效,第二个给了我 Object not found!
错误,我不明白哪里出了问题,谁能帮我理解一下。
所以我的文件夹结构就像 appname/public/index.php
我 运行 第一种方法通过简单地调用 appname/public/
第二个我 运行 它喜欢 appname/public/hello
您需要按照以下规则在您的根目录中添加 .htaccess 文件(很可能 appname/public)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
希望它能奏效。
我已经使用 slim 一段时间了,今天我更新到 3.8 并且开箱即用,我发现了一些东西
$app->get('/', function ($request, $response) {
return 'Slim working';
});
$app->get('/hello', function ($request, $response) {
return 'Slim hello also working';
});
第一个方法调用有效,第二个给了我 Object not found!
错误,我不明白哪里出了问题,谁能帮我理解一下。
所以我的文件夹结构就像 appname/public/index.php
我 运行 第一种方法通过简单地调用 appname/public/
第二个我 运行 它喜欢 appname/public/hello
您需要按照以下规则在您的根目录中添加 .htaccess 文件(很可能 appname/public)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
希望它能奏效。