web.phpに以下のルートがあります。最初のルートは常に機能しますが、次のようなURLを使用すると、2番目のルートは機能しません。
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');
しかし、成功しません。よろしくお願いします。
/
これらのパラメーターの間に追加する必要があります。そうしないと、Laravelはこれらを1つの長い文字列として認識します。
Route::get('ads/{location?}/{category?}/{keyword?}', 'Categories@check_if_category')->name('route_f_category_page');
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加