$request = new Symfony\Component\HttpFoundation\Request()
$request->getRequestUri();
Seems to return the path and the query params. How to I get just the path?
$request = new Symfony\Component\HttpFoundation\Request()
$request->getRequestUri();
Seems to return the path and the query params. How to I get just the path?
strtok($request->getRequestUri(), '?');
...or...
$request->getBaseUrl() . $request->getPathInfo();
Or you can use just PHP for that matter :
$urlWithoutQueryString = strtok($_SERVER["REQUEST_URI"], '?');
None of the above worked for me in Laravel 5.7. I ended up using the following to get the full request URI without the query string:
$uri = strtok($request->getUri(), '?');
This will return https://example.com/request/uri for a request made to https://example.com/request/uri?param=1.