Add an anchor to Laravel redirect back

后端 未结 2 540
無奈伤痛
無奈伤痛 2021-02-18 21:49

In a Laravel controller I have this redirect:

    return redirect()->back();

Which returns me to my previous page (say http://domain/page).

2条回答
  •  既然无缘
    2021-02-18 22:31

    return Redirect::to(URL::previous() . "#whatever");
    

    And remember to import it at the top:

    use Illuminate\Support\Facades\Redirect;
    use Illuminate\Support\Facades\URL;
    

    I hope this works for you!

提交回复
热议问题