I have the following routes for a webshop with categories and products:
Route::name('shop.products.view')->get('/p/{productUrl}', 'Shop\ProductsController@view');
Route::name('shop.categories.view')->get('/c/{categoryOne}/{categoryTwo?}/{categoryThree?}', 'Shop\CategoriesController@view')
categoryTwo is a subcategory of categoryOne
categoryThree is a subcategory of categoryTwo
This works perfect but I need to put .html at the end so the url's are exactly the same as the url's from the old webshop.
For the productpage this is no problem:
Route::name('shop.products.view')->get('/p/{productUrl}.html', 'Shop\ProductsController@view');
If I do this for the category page it doesn't work when the optional parameters are not filled.
Route::name('shop.categories.view')->get('/c/{categoryOne}/{categoryTwo?}/{categoryThree?}.html', 'Shop\CategoriesController@view')
This results in: domain.com/c/category1//.html
Any ideas on how to solve this so I get:
domain.com/c/category1.html
domain.com/c/category1/category2.html
domain.com/c/category1/category2/category3.html