如何为以下URL创建路由';s在拉腊维尔


How to create routes for the following URL's in Laravel

localhost/public/Products-product-name1 //Product names are alphanumeric
localhost/public/Products-product-name2
localhost/public/Products-product-name3
localhost/public/Products-product-name4
......

如何为具有以下前缀Products- 的url指定单个根

Route::post('Products-','ProductsController@getProducts');

有人能推荐我吗?

您可以简单地使用路由参数:

Route::post('Products-{product}', 'ProductsController@getProducts');

在你的控制器里:

public function getProducts($product = 'product-name1')
{
    ...
}