I have this code on my routes.php
file that do a redirect. Though the problem is that whenever I ran php artisan route:cache
command, it gives me an error of Unable to prepare route [article/{params}] for serialization. Uses Closure.
I know this has something to do with routes not allowing it to be cached if it have a closure. But how could I make a workaround for this redirect?
Route::get('article/{params}', function($params) {
return Redirect::to($params, 301);
});
Since Laravel 5.5
you can use:
Route::redirect('/here', '/there', 301);
See the documentation under Redirect Routes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With