1
1

More than 3 years have passed since last update.

Laravelのルーティングで「全てのパス」を指定する

Posted at

Laravelのルーティングで「全てのパス」を指定するには、
{all} をパスの部分に指定すればよい。
下記のように。

routes/web.php
Route::get('{all}', function() {
  return redirect('/');
});

上記をweb.phpの末に記載すれば、GETリクエストでマッチするパスがなかった際に、ルートにリダイレクトされるようになる。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1