phprouteszend-framework2zend-routeslash

ZF2 route parameters with slash


Is it possible to assemble a route with parameters containing forward slashes?

Config:

'someroute' => array(
       'type' => 'Zend\Mvc\Router\Http\Segment',
       'options' => array(
                'route' => 'someroute/:path',
                'defaults' => array(
                    'controller' => 'Controller',
                    'action' => 'index'
                ),
                'constraints' => array(
                    'path' => '(.)+'
                )
       )
 )

Controller:

$path = 'some/subdirectory';
$this->url('someroute', array('path' => $path));

Results in:

http://host.name/someroute/some%2Fsubdirectory

Solution

  • Using rawurldecode() in the view solves this issue of course.