Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to get current url path in laravel

// Full URL with query string
print $request->fullUrl(); // http://127.0.0.1:8000/sometext?city=hyd

// Get the path part of the URL 
print $request->path(); // sometext

// Root (protocol and domain) part of the URL)
print $request->root(); //http://127.0.0.1:8000

//Get the full URL for the previous request
print url()->previous();

//tested on Laravel 5.6

//OR 

use IlluminateSupportFacadesURL;
 
print URL::current();
Source by laravel.com #
 
PREVIOUS NEXT
Tagged: #current #url #path #laravel
ADD COMMENT
Topic
Name
1+4 =