【发布时间】:2013-11-07 03:39:49
【问题描述】:
我在使用 Laravel 时遇到了一些路由问题。我认为是因为我没有采取好的方法但是......
这是我的代码:
Route::group(array('prefix' => 'products'), function()
{
Route::get('', array('uses'=>'products@index'));
//show all the products
Route::get('{Categorie}',array('uses'=>'products@categorie'))->where('Categorie','^[A-Z][a-z0-9_-]{3,19}$');
//show the products of this categorie
Route::get('{shopname}',array('uses'=>'products@shopname'))->where('shopname','^[a- z][a-z0-9_-]{3,19}$');
//show the product of this shopname
});
Route::group(array('prefix' => '/products/{:any}'), function()
{
//no index because productName is not optionnal
Route::get('{productName}', array('uses'=>'product@getProduct'));
//the Product controller is now SINGULAR
//show this product in particular
});
所以它适用于第一组...... mysite.fr/products => 好的 mysite.fr/MyCategorie => 好的 mysite.fr/mashopname => 好的
但是当我添加第二个参数时:
mysite.fr/products/myshopname/myfirstproduct
我收到了一个带有特定消息的错误...
非常感谢您的帮助!
【问题讨论】:
标签: php laravel laravel-4 laravel-routing