Laravel Get Current URL With Parameters

To get the current URL with parameters, domain, etc in laravel; In this tutorial, we will learn how to get the current URL with parameters, current URL Path on controller and blade views in laravel 10|9|8 apps.

How to Get Current URL in Laravel 10|9|8

Using the following url()->full(), Request::url(), url()->current(), you can get url path in laravel 10|9|8 apps:

  • Get Global and Current URL
  • Get Current URL path
  • Get the previous URL in Laravel

Get Global and Current URL

You can get current URL, global url with the query string in laravel apps using url(), url()->current, url()->full(); as follows:

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();

Get Current URL path

Using the laravel path() method, you can get the current path of url in laravel:

 $request->path() 

Get the previous URL in Laravel

Sometimes you 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.

Recommended Laravel Tutorials

Recommended:-Laravel Try Catch

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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