大家好。有以下路线:
Route::get('catalog/{parentCat}/{childrenCat}/{productAlias}-{productId}.html',
['as' => 'productPage', 'uses' => 'ProductController@index']
)->where('productAlias', '([0-9]+)-([A-Za-z]+)-([-\w]+)');
它适用于至少包含 2 个破折号 (-) 的 URL。为什么会这样?那些。在链接上:catalog/flowers/roses/101-rose-2.html
这条路线不起作用,但它不起作用http://larashop.loc/catalog/flowers/roses/101-rose-60sm-2.html
。如何使其适用于第一个选项?是否可以在正则表达式中使表达式([-\w]+)
可选?
试试这个选项: