I am working on a system that receives a request to a URL and forwards the request to a different URL after performing some actions (not relevant for the question). Example: The system receives a GET request to http://localhost/users/123/my/path?foo=1&bar=abc
and then forward the user to http://localhost/my/path?foo=1&bar=abc
using GET as well. Getting the new path and arguments is not a problem.
Using redirects works perfectly when there are no arguments. However, I need to keep all the request data, like method name (GET, POST, etc) and arguments, which does not work with the redirect($newRoute)
. According to Laravel documentation and some experiments I tried, redirect($newRoute)->whith($params)
works only for URL parameters, like http://localhost/{$id}/some/path
, but not for http://localhost/some/path?id=456
, for example.
I also tried creating a new request based in the old one. It works fine except for one essential detail: the URL in the browser remains the old one. Exemple: when requesting http://localhost/users/123/my/path?foo=1&bar=abc
, the system behaves as expected but stays in the same URL, not the right one (http://localhost/my/path?foo=1&bar=abc
). It is a requirement that the system return/go to the new URL. I create the new request like this, as in here:
$newRequest = Request::create("/" . $newRoute, $originalRequest->getMethod(), $originalRequest->all());
return Route::dispatch($newRequest);
Any thoughts on how can I accomplish what I need?
Thanks guys!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Ixbqqq
via IFTTT
Aucun commentaire:
Enregistrer un commentaire