Zend Skeleton应用专辑教程404

时间:2015-06-07 15:26:25

标签: php zend-framework zend-framework2

据我所知,我已经跟着Zend skeleton application tutorial到了字母(我实际上经历过两次相同的结果)但是当我尝试访问zf2-tutorial.localhost/album时,我得到了以下错误:

A 404 error occurred
Page not found.
The requested URL could not be matched by routing.

No Exception available
© 2005 - 2015 by Zend Technologies Ltd. All rights reserved.

转到zf2-tutorial.localhost显示Zend欢迎页面,404包含在Zend样式中,因此至少看起来有效。

我尝试过类似问题herehere提供的解决方案,但无济于事,任何想法都会受到赞赏。感谢。

编辑:我正在使用XAMPP本地运行教程。

4 个答案:

答案 0 :(得分:0)

要解决与配置服务器以使用zend相关的问题,我建议您安装WAMP服务器。然后通过将zend文件上传到子目录,您将能够使用zend开始。

答案 1 :(得分:0)

也请尝试使用以下提供的.htaccess

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

答案 2 :(得分:0)

似乎此错误与.htaccess无关,其配置问题。请确保您已在Album \ config \ module.config.php文件中定义了所需的腐败:

http://framework.zend.com/manual/current/en/user-guide/routing-and-controllers.html#routing-and-controllers

答案 3 :(得分:0)

事实证明,在module.config.php中我错误地将控制器和路由器的数组拆分为两个数组。将它们组合成一个似乎已经解决了这个特殊问题。

代码如下:

 return array(
 'controllers' => array(
     'invokables' => array(
         'Album\Controller\Album' => 'Album\Controller\AlbumController',
        ),
    ),

  'router' => array(
         'routes' => array(
             'album' => array(
                 'type'    => 'segment',
                 'options' => array(
                     'route'    => '/album[/:action][/:id]',
                     'constraints' => array(
                         'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                         'id'     => '[0-9]+',
                     ),
                     'defaults' => array(
                         'controller' => 'Album\Controller\Album',
                         'action'     => 'index',
                     ),
                 ),
             ),
         ),
     ), 
);