Laravel Redirect Status Code

Laravel’s documentation doesn’t make this obvious, but when you are using a redirect you can change what the status code of the redirect is.

Route::get('some/route', function(){
    return Redirect::to("another/route", 301);
});
Route::get('some/route', function(){
    return Redirect::route("another.route", null, 301);
});

The tricky part is knowing which parameter is the status code. To check which parameter it is, refer to the Redirector Class.

No Comments

Post a Comment