2

I am trying to send all undefined routes in a specific controller like this:

Route::get('/{slug:[A-Za-z0-9:/]+}', ['uses' => '\Site\Http\Controllers\AppController@index'])

It works in Lumen 5.1 but no chance in Laravel 5.2.

How can I setup such general match routes?

Blitzkoder
  • 1,768
  • 3
  • 15
  • 30
user237329
  • 809
  • 1
  • 10
  • 27

3 Answers3

0

I didn't test it, but something like this should work:

Route::get('/{slug}', 'AppController@index')->where('slug', '([A-Za-z0-9:/]+)');
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
0

Put this after all of the relevant other routes:

Route::get('/{slug}', '\Site\Http\Controllers\AppController@index');
Lance Pioch
  • 1,147
  • 6
  • 18
0

Route Undefined = 404 Error, so you can handle it properly.

Look at this question: Redirect to homepage if route doesnt exist in Laravel 5

Community
  • 1
  • 1
Claudio King
  • 1,606
  • 1
  • 10
  • 12