Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dougd_nc's avatar

get current URL path without protocol and domain

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.

0 likes
3 replies

Please or to participate in this conversation.