【发布时间】:2018-06-23 19:53:30
【问题描述】:
我在 web.php 中有以下路由,第一个路由总是有效,但如果我使用像这样的 url,第二个则不会
ads/mobiles
然后函数 check_if_category 执行良好。但我使用 url 之类的
ads/lahore/mobiles
在这种情况下,它会重定向到 404 页面。
Route::get('ads/all', 'AdControllerWithoutAuth@all_ads')->name('route_all_ads');
Route::get('ads/{location?}{category?}{keyword?}', 'Categories@check_if_category')->name('route_f_category_page');
我也是这样工作的
Route::get('ads/all', 'AdControllerWithoutAuth@all_ads')->name('route_all_ads');
//Route::get('ads/{location?}', 'Categories@check_if_category')->name('route_f_category_page');
//Route::get('ads/{location?}{category?}', 'Categories@check_if_category')->name('route_f_category_page');
Route::get('ads/{location?}{category?}{keyword?}', 'Categories@check_if_category')->name('route_f_category_page');
但没有成功。提前感谢您的帮助。
【问题讨论】:
标签: php laravel routes laravel-5.3