I want to redirect all "gets" from "/products/PRODUCTNAME" to "/product/PRODUCTNAME". I tried to do it with Route::redirect:
Route::redirect('/products/{name}', '/product/{name}');
But, if I go to "mypage.com/products/HJ-3000" it's supposed to redirects me to "mypage.com/product/HJ-3000", but I get, textually, "mypage.com/products/{name}".
I know I can do it with Route::get, but I want to know how can I do it with Route::redirect.
You can try this
Route::get('/products/{name}', function ($name) {
return Redirect::to('/product/$name');
});
With Route::redirect
Route::redirect('/products/{name}', str_replace_first('/products/{name}', '/product/{name}', Request::fullUrl()), 301);
Route::redirect with wildcard in Laravel 5.5+
**not tested