ZF2 routes with parameters containing slashes

The routing system of ZF2 is pretty flexible, which is nice in case you need something custom like I did today. I needed to be able to handle some Base64 parameter data and so it’s possible that this data will contain slashes. Therefore a plain vanilla segment route like this won’t work:

          'my-route' => array(
	            'type' => 'Segment',
	            'options' => array(
		            'route' => '/myroute/:encdata',
		            'defaults' => array(
			            'controller' => 'Application\Controller\MyController',
			            'action' => 'handle-enc-data',
			            'encdata' => null,
		            ),
	            ),
            ),

When my URL would be something like this the route wouldn’t be matched because of the slash characters inside of the Base64 parameter:
http://my.local/myroute/c3ViamVjdHM/X2Q9MQ==

A regex route can solve this problem. It’s actually pretty simple:

          'my-route' => array(
	            'type' => 'regex',
	            'options' => array(
		            'regex' => '/reg4p/(?.*)',
		            'spec' => '/reg4p/%encdata%',
		            'defaults' => array(
			            'controller' => 'Application\Controller\MyController',
			            'action' => 'handle-enc-data',
			            'encdata' => null,
		            ),
	            ),
            ),