xxxxxxxxxx
\Route::current()
############### OR ####################
$request->getRequestUri()
xxxxxxxxxx
// 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 Illuminate\Support\Facades\URL;
print URL::current();
xxxxxxxxxx
Get the current url
here using the Request::url() method. It will return the entire URL, but strip the query string from it.
<p> Url: {{ Request::url() }} </p>
Output
Url: http://localhost:8000/post/demo
xxxxxxxxxx
//get current url
use Illuminate\Support\Facades\Route;
Route::getFacadeRoot()->current()->uri();
//get current full url
$url = url()->current();
xxxxxxxxxx
get URL:
{{ Request::url() }} // http://localhost/path
get path:
{{ Request::path() }} // path