Best Practice for HTTP Redirect

Posted 2 years ago by Tipoff

I'm reading the documentation on redirects (https://laravel.com/docs/5.4/redirects), but having some trouble setting one up the way I want. I have a quotes database table with an id column that begins incrementing at 1,000,000 so there will always be 7 digit id numbers for them. I want people to visit mywebsite.com/1000000 and be redirected to mywebsite.com/quotes/quotations/1000000 and have tried the following to no avail:

Route::get('quotes/quotations/{quote}', '[email protected]');

Route::get('{quote}', function () {
    return redirect()->action(
    '[email protected]', ['id' => {quote}]

I have also tried things like:

Route::get('quotes/quotations/{quote}', '[email protected]');

Route::get('{quote}', function () {
    return redirect('quotes/quotations/{quote}');

My main route works, but both attempts at the redirect are failing. I think it is not passing along the prior {quote} id value, but I can't find an example with this to fix it. Any help and advice on the best practice for implementing this would be appreciated. Thanks

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.