You can use this.
$uri = $request->path();
https://laravel.com/docs/10.x/requests#retrieving-the-request-path
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
If the current URL is https://mydomain.com/mypath/edit?x=2
Is there a function that will just give me the following?
/mypath/edit?x=2
When adding a link in a form, the domain and protocol are unneeded and the protocol just causes problems if it's the wrong one.
2nd thing:
Request::url() returns a URL with the "http" protocol, even with URL::forceScheme('https'); in AppServiceProvider boot()
Even when the page is requested via https. That's the main reason I can't use that url. However, it should be irrelevant if I can just get the path without the protocol or domain.
Please try to use
\Request::getRequestUri();
Please or to participate in this conversation.