We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Duplicate url when redirecting

I have login page and after successful login it redirects to other page with this code

return $this->response->redirect(array('for'=>'products'));

But it redirects to /products/products instead of /products. I tried to change to

return $this->response->redirect('products');

with the same result. Route:

$router->add('/products', array(
    'controller'=>'products',
    'action'=>'index'
))->setName('products');
edited Mar '14

use:

return $this->response->redirect(array('for'=>'products'));
edited Mar '14

@xboston I use it and it redirects to wrong url.



98.9k

I'm running this gist https://gist.github.com/phalcon/de473f88ee70d0462155 with your code here https://test.phalcon.io/r.php and it seems to be working

When I check url like in your gist it also gives me just /products. Actually there are two redirects maybe it causes problem. As I said there's login page where after login (using session) it redirects to other controller which check user role and redirects to appropriate page ( one of them is /products). And it duplicates them. Added code to gist https://gist.github.com/tiix/a0dd611d0098fd03b2d9