Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 路由在zend 2中不起作用_Php_Routes_Zend Framework2 - Fatal编程技术网

Php 路由在zend 2中不起作用

Php 路由在zend 2中不起作用,php,routes,zend-framework2,Php,Routes,Zend Framework2,现在我在zend 2工作 我在module.config.php中有以下路径 'router' => array( 'routes' => array( 'apps' => array( 'type' => 'segment', 'options' => array( 'route' => '/apps[/:action][/:id]', 'constraint

现在我在zend 2工作

我在module.config.php中有以下路径

'router' => array(
'routes' => array(
    'apps' => array(
        'type'    => 'segment',
        'options' => array(
            'route'    => '/apps[/:action][/:id]',
            'constraints' => array(
                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                'id'     => '[a-zA-Z0-9]+',
            ),
            'defaults' => array(
                'controller' => 'Apps\Controller\Apps',
                'action'     => 'index',
            ),
        ),
    ),
),),
我的url是/project/apps/xx,它显示了这样一个错误

A 404 error occurred
Page not found.
The requested controller was unable to dispatch the request.
Controller:Apps\Controller\Apps
但是,当我传递一个整数时,它会毫无问题地工作。(例如:/project/apps/22)


有什么想法吗?谢谢

我刚刚将您的routes阵列插入我的ZF2项目,无论是否使用id,它都可以正常工作。您能提供更多详细信息吗?我注意到你进入了/project/apps。此/项目是否为别名,是否使用虚拟主机?您的应用程序中是否有可用的路由?我的路由是localhost/projectname/apps/id。(此处apps是控制器名称。)以下路由可以正常工作。。localhost/projectname/apps/22。。localhost/projectname/apps/1X。。和localhost/projectname/apps/1X1。。当路由是这样时就会出现问题:localhost/projectname/apps/XX(当id只有两个字母或一个整数跟一个字母)是的,我明白了。我认为您需要为您的项目创建一个虚拟主机。这会解决你的问题。我不认为你的问题在于你的代码。