I cannot find info for redirecting as 301/302 in the Laravel docs.
In my routes.php file I use:
Route::get(\'foo\', function(){
return Redirect::to(
martinstoeckli's answer is good for static urls, but for dynmaic urls you can use the following.
Route::get('foo/{id}', function($id){
return Redirect::to($id, 301);
});
Live Example (my use case)
Route::get('ifsc-code-of-{bank}', function($bank){
return Redirect::to($bank, 301);
});
This will redirect http://swiftifsccode.com/ifsc-code-of-sbi to http://swiftifsccode.com/sbi
One more Example
Route::get('amp/ifsc-code-of-{bank}', function($bank){
return Redirect::to('amp/'.$bank, 301);
});
This will redirect http://amp/swiftifsccode.com/ifsc-code-of-sbi to http://amp/swiftifsccode.com/sbi