Home > Back-end >  Get previous url in laravel
Get previous url in laravel

Time:09-17

I am trying to get previous url in laravel, I have tried this code,

        echo redirect()->back()->getTargetUrl();
        die();

when i simply echo this code, This correctly returns the url, but when i try to save it in some variable, It does not work

CodePudding user response:

You can find it in the docs.

https://laravel.com/docs/8.x/urls#accessing-the-current-url

// Get the current URL without the query string...
echo url()->current();

// Get the current URL including the query string...
echo url()->full();

// Get the full URL for the previous request...
echo url()->previous();
  • Related