phpzend-frameworkzend-routezend-router

Zend Framework route not working when passing URLs as route parameters


When I try to pass a URL in the route below it gives me 404 error. If I replace the URL with any other string it works.

This is the route.

$route = new Zend_Controller_Router_Route(
                'user/logout/:preserve/:ref',
                array(
                        'action'     => 'logout',
                        'controller' => 'user',
                        'module'     => 'root',
                        'preserve' => false,
                        'ref' => ''
                )
        );
        $router->addRoute('logout', $route);

This is how I am generating URLs in my views.

<a href="<?php echo $this->url(array('preserve' => 1, 'ref' => $this->url()), 'logout'); ?>">Logout</a>

This is the URL which is generated by the URL view helper.

/user/logout/1/http%3A%2F%2Feop.localhost.com%2F

I can't figure out why this isn't working. Can anyone please help with this?

Thanks.


Solution

  • I managed to solve the problem by applying the urlencode() function to my generated URL.

    I hope it saves someone else some time.