Route content:

Route::get('category/{category}', 'Product_Controller@index'); 

Contents of the controller:

 $data = Category::where('alias', $category) ->firstOrfail(); 

Record in the database:

 поле alias = 'category/subcategory' При переходе на страницу site.com/category/subcategory выдает ошибку: (1/1) NotFoundHttpException 

How to fix this error?

    2 answers 2

    Change the route description as follows:

     Route::get('category/{category}', 'Product_Controller@index') ->where(['category' => '(.*)']); 

      Instead

       $data = Category::where('alias', $category) ->firstOrfail(); 

      Make a

       $data = Category::where('alias', "category/{$category}") ->firstOrfail();