1

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

1

1 Answer 1

6

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.