Klein PHP路由不工作

Klein PHP路由不工作,php,Php,我从另一个选择Klein作为路由框架的开发人员那里获得了一个应用程序的开始。我对Slim更为熟悉,但对于我来说,我仍然无法理解为什么以下方法不起作用: $klein->respond('GET', '/?', function($request, $response) { echo 'this works!' }); $klein->respond('GET', '/[i:id]', function($request, $response) { echo 'This

我从另一个选择Klein作为路由框架的开发人员那里获得了一个应用程序的开始。我对Slim更为熟悉,但对于我来说,我仍然无法理解为什么以下方法不起作用:

$klein->respond('GET', '/?', function($request, $response) {
    echo 'this works!'
});
$klein->respond('GET', '/[i:id]', function($request, $response) {
   echo 'This returns 404 not found';
});
$klein->dispatch();
.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L] 
在我的httpd.conf中,我有“AllowOverride All”


我相信这很简单,但就我个人而言,我不明白为什么第二条路线不起作用。

考虑两种路线模式

“/?”
路由模式匹配
scheme:host
schema:hostname/
<代码>/是可选的

/[i:id]
路由模式匹配
scheme:host/id
,其中id是一个整数

使用
/
(例如
scheme:host/2/
)终止后一个路由模式的请求uri将不匹配,除非路由模式更新为与此情况匹配


为了匹配这种情况,请使用
/[i:id]/?
作为路由模式。

哈哈,我不知道为什么我要在404模式中加入echo,不过,嘿,你明白了。