Php Zend Framework:在此服务器上找不到请求的Url

Php Zend Framework:在此服务器上找不到请求的Url,php,apache,.htaccess,zend-framework,zend-framework2,Php,Apache,.htaccess,Zend Framework,Zend Framework2,这里似乎有很多类似的问题,但我发现我的版本解决了这个问题,我通过本地OSXWeb服务器运行zend skeleton框架 导致标准路线如下:http://localhost/~adam/api/public/ 为使我的应用程序按预期工作,已更改到默认索引的路由: 'routes' => array( 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal',

这里似乎有很多类似的问题,但我发现我的版本解决了这个问题,我通过本地OSXWeb服务器运行zend skeleton框架

导致标准路线如下:
http://localhost/~adam/api/public/

为使我的应用程序按预期工作,已更改到默认索引的路由:

     'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'create',
                ),
            ),
        ),
当我创建一条新路线时,遵循相同的想法,它看起来是这样的:

       'list' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/list',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'list',
                ),
            ),
        ),
所以它链接到同一个控制器,理论上,我应该可以访问
http://localhost/~adam/api/public/list
,它应该可以工作,但我找不到页面

我看到有人建议这可能与当前默认的.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]
我还看到有人建议您必须编辑/etc/apache2/httpd.conf文件,设置
AllowOverride all
,而不是
AllowOverride none
,但这要么不起作用,要么我做得不正确,我尝试了一些变体,结果是:

<Directory "/~adam/api/public">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
DirectoryIndex.html

假设这是我需要的正确解决方案,有人能指出我哪里出了问题吗?或者建议如何解决此问题。由于conf中有几个目录列表,我可能更改了错误的目录吗?

这个问题是由路由匹配引起的

如果您提到像'route'=>'/list',,那么它看起来是从localhost。但是,列表是~adam项目下的一个模块

要解决此问题,请创建虚拟主机。如果您使用的是虚拟主机,则“/list”将从您的(虚拟)主机名中查找

否则,您必须这样指定

'route' => 'http://localhost/~adam/list'

但这是一种不好的方法。

目录路径/~adam/api/public指向正确的directroy吗?不确定,本地web服务器目录是/user/adam/sites/api-不确定是要将其用作目录还是上述目录我主要使用nginx,但我认为应该是/user/adam/sites/api