Laravelのルーティングでリダイレクトを設定する方法について。
リダイレクトする方法
Routeファサードのredirectメソッドを使う。
デフォルトの設定(302)
・Route::redirect('here', 'there');
┗ here: requestされたパス
┗ there: リダイレクト先のパス
デフォルトでは302リダイレクト(一時的なリダイレクト)になる。
▼実例
Route::redirect('xxx', '/');

xxxにアクセスすると、/が表示される。
恒久的なリダイレクト(301)
・Route::redirect('here', 'there', 301);
▼実例
Route::redirect('xxx', '/', 301);

恒久的なリダイレクト (permanentRedirectメソッド)
permanentRedirectメソッドを使っても301転送ができる。
・Route::permanentRedirect('here', 'there');
▼実例
Route::permanentRedirect('xxx', '/');