【发布时间】:2015-08-28 23:52:18
【问题描述】:
我正在使用 Slim Framework 3(最新测试版)。路由规则已更新,现在扩展了 nikic/FastRoute。
我无法让“结束于”路线正常工作。以下是我的两条路线:
$app->get('/{uri:.*(?:css|js|gif|jpg|jpeg|png)$}', function (){ [...] });
$app->get('/{uri:.*}', function (){ [...] });
根据 FastRoute,我们不能使用正则表达式多匹配块 (),但他们建议使用反向引用块来获得相同的效果:https://github.com/nikic/FastRoute#defining-routes
但是,这不起作用。
我想要做的是做一个包罗万象的路线,专门针对网页资产(图像等)使用不同的路线。
【问题讨论】:
-
我使用
$app->get('/asset/{asset:[a-z]+\.(?:css|js)}', function($req, $res, $args) {生成资产,但我认为这不是“以”结尾。