views:

289

answers:

1

This is my code:

$route = new Zend_Controller_Router_Route_Regex('download/([^/]+)(/([^/]+))?/(\d+)/(\d+)',
                                            array('controller' => 'download',
                                                  'action'     => 'load'),
                                            array(1 => 'name', 3 => 'or_name',
                                                  4 => 'p_id', 5 => 'c_id'));
$router->addRoute('download', $route);

The first param should be allowed to contain slashes but in urlencoded form. But unfortunately it's not working with my current code, it gives me a 404 error instead.

So, is it possible to prevent route parameters from being urldecoded?

+1  A: 

Within Zend_Controller_Router_Route_Regex::match, it calls urlencode on the path right away:

$path = trim(urldecode($path), '/');


To defeat that, try urlencoding your name parameter twice:

$url = 'download/'.urlencode(urlencode('hey/there'));
Derek Illchuk
That is a solution indeed, but I'd rather want it not to be a hack
EarthMind
you can write custom router
SM