Laravel Get Current URL Example

Laravel get the current URL. This tutorial demonstrates to you how you can get the current URL in laravel. Also, this tutorial shows you how you can get the previous URL in laravel

How to Get Current Request URL

Us the below give a method for get current URL without the query string

echo \Request::url();

Use global url function

echo url()->url();

Use the current function

echo url()->current();

Get current full URL with query string parameters

echo url()->full();

How to get Current URL path

Use the below method for- get the current path in laravel

 $request->path() 

Get the previous URL in Laravel

Sometimes we need to check what was the last requested or previous URL, it is simple to do in laravel here is how

echo url()->previous();

If you have any questions or thoughts to share, use the comment form below to reach us.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *