0

我想将两条路线:/ 和 /articles 映射到相同的方法 list_articles。

我尝试使用此代码,但它不起作用。

 $app->get('/:route', function () use($app, $layout) {
    list_articles();
 })->conditions(array("route" => "(/|articles)"))->name('list_articles');

我打错了什么?

4

1 回答 1

0

Here is how to add the document root (/) to the list of routes. It says "do stuff" for both / and /articles.

 $app->get('/:route', function () use($app, $layout) {
     echo "do stuff"
 })->conditions(array("route" => "(|articles)"))->name('list_articles');

The

 ->name('list_articles')

part just names the route to be 'list_articles'

于 2013-09-01T03:13:46.110 回答