I want to redirect a user from one url to another. I used $this->redirect()->toRoute()
but i've noticed that the application runs twice as if the user made 2 requests.
Of course you have 2 requests. Because the following will happen:
Maybe a workaround is not to use redirect()
, but forward()
. The disadvantage is that you are still on /someroute
while getting response from /otherroute
.
I'm not very familiar with ZF2, but in PHP you can use
header('Location:www.url.com');
Can you try it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.