【发布时间】:2013-01-01 16:10:26
【问题描述】:
我有一个 L3 应用程序正在尝试移植到 L4。在 L3 版本中,我的一条路线是
Route::get('/(:any)/(:all?)', etc...
这让我可以处理任意数量的 URL 段,例如:
/contact_page
/store_category
/store_category/shirts_category
/store_category/shirts_category/specific_shirt_page
/an/arbitrary/number/of/nested/categories
但在 L4 中,我无法弄清楚如何模拟 (:all?) 的功能
以下代码有效:
Route::get('/{arg1?}/{arg2?}/{arg3?}', function($arg1='home', $arg2, $arg3)
{
//do something
});
所以我可以添加大量可选参数(比我认为在实际使用中需要的更多)但这不是很优雅。
在 Laravel 4 中有什么方法可以定义一个可以响应任意数量的 URL 段的路由吗?
【问题讨论】:
标签: php url-routing laravel laravel-4