F
F
frontendo2017-06-12 14:52:12
Laravel
frontendo, 2017-06-12 14:52:12

How to correctly write a route for returning the same page to any get-request?

Now such a sheet is written, but I would like to do it in one fell swoop
Route::get('/', function () {
return view('index');
});
Route::get('/{x}', function () {
return view('index');
});
Route::get('/{x}/{y}', function () {
return view('index');
});
Route::get('/{x}/{y}/{z}', function () {
return view('index');
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-06-12
@frontendo

For SPA I use this

Route::get('{path}', function () {
    return view('index');
})->where('path', '(.*)');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question