Laravel 10 Get Current URL Example

In this article, we will see laravel 10 get the current URL example. Here, we will learn about how to get the current URL in laravel 10 and laravel 11. if you want to get the current page URL in laravel 10 then we can use many methods like current(), full(), request(), url().

Also, you can get the current URL and the previous URL in laravel 11.

So, let's see, how to get the current URL in laravel 10 and laravel 11, laravel 11 gets the current URL with parameters, and get the full URL in laravel 10.

Example: full()

In this example, we will get the current URL including the query string.

$currentFullURL = url()->full();

echo "<br>Full URL: ".$currentFullURL;



Example: current()

In this example, we will get the current URL without the query string.

$currentURL = url()->current();

echo "<br>Current URL: ".$currentURL ;


Example: Get URL using Facades

In this example, we will get a URL using Facades.

use Illuminate\Support\Facades\URL;

$URLFacades = URL::current();

echo "<br>URL Facades: ".$URLFacades;


Example: full() with Facade and Query string parameters

Also, you can get full URLs using URL facades.

$currenturl = URL::full();



Example: Get the Previous URL

In this example, we will get the full URL for the previous request.

$previousURL= url()->previous();

echo "<br>Previous URL: ".$previousURL;



Example: Get Current Route Name

In this example, we will get the current route name.

$cur_route = \Route::current()->getName();

echo "<br>Current Route: ".$cur_route;


Example: Get Previous Route Name

In this example, we will get the previous route name.

$previous_Route_Name = app('router')->getRoutes()->match(app('request')->create(URL::previous()))->getName();

echo "<br>Previous Route Name: ".$previous_Route_Name;


Example: Request::is

In this example, you can check the request path.

$request_example = \Request::is('index') ? 'index path' : 'other path';

echo "<br>Request is: ".$request_example;

// For Blade File

<li class="{{ Request::is('admin/dashboard') ? 'active' : '' }}">Dashboard</li>



Full URL: http://localhost:8000/index?

Current URL: http://localhost:8000/index

URL Facades: http://localhost:8000/index

Previous URL: http://localhost:8000/index?

Current Route Name: index

Previous Route Name: index

Request is: index path


You might also like:


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.