この方法でリダイレクトしています。私はこのように間違っていると思います。より良い方法を教えてください。
<a href="<?php echo $this->serverUrl()."/restaurantlist/view/".$list['id']."/".$list['name']?>">
<img alt="" src="<?php echo $image; ?>">
</a>
私のmodule.config.phpのコード
<?php
return array(
'controllers' => array(
'invokables' => array(
'Restaurantlist\Controller\Restaurantlist' => 'Restaurantlist\Controller\RestaurantlistController',
),
),
'router' => array(
'routes' => array(
'Restaurantlist' => array(
'type' => 'segment',
'options' => array(
// Change this to something specific to your module
'route' => '/restaurantlist[/]',
'defaults' => array(
'controller' => 'Restaurantlist\Controller\Restaurantlist',
'action' => 'list',
),
),
'may_terminate' => true,
'child_routes' => array(
'view' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/]view[/:id][/:name][/]',
'constraints' => array(
'name' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Restaurantlist\Controller\Restaurantlist',
'action' => 'view',
),
),
),
),
),
),
),
'view_helpers' => array(
'factories' => array(
'Requesthelper' => function($sm){
$helper = new \Restaurantlist\View\Helper\Requesthelper;
$request = $sm->getServiceLocator()->get('Request');
$helper->setRequest($request);
return $helper;
}
)
),
'view_manager' => array(
'template_path_stack' => array(
'Restaurantlist' => __DIR__ . '/../view',
),
),
);
http://test.localhost.com/restaurantlist/view/157/Bluestemのようにリダイレクトされ、 問題なく動作しますが、この http://test.localhost.com/Bluestem または http://test.localhost が 必要です。 com/157-ブルーステム
私はたくさん試しましたが、成功しませんでした。