简体   繁体   English

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

[英]Zend Framework: The Requested Url was not found on this server

There seems to be a lot of similar issues around there but non that i've found that solve my version of the problem, im running the zend skeleton framework through the local osx web server. 那里似乎有很多类似的问题,但是我发现并没有解决我的问题,即通过本地osx Web服务器运行zend框架。

resulting in the standard route being the following: http://localhost/~adam/api/public/ 导致标准路由如下: http://localhost/~adam/api/public/

The route to the default index has been changed for the purpose of my application which works as intended: 出于我的应用程序的目的,更改了默认索引的路由,该应用程序可以按预期工作:

     'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'create',
                ),
            ),
        ),

When i create a new route, following the same idea it looks like this: 当我创建一条新路线时,遵循相同的想法,它看起来像这样:

       'list' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/list',
                'defaults' => array(
                    'controller' => 'Application\Controller\Testimonial',
                    'action'     => 'list',
                ),
            ),
        ),

so it links to the same controller and in theory, i should just be able to access http://localhost/~adam/api/public/list and it should work however i get page not found. 所以它链接到相同的控制器,并且从理论上讲,我应该只能访问http://localhost/~adam/api/public/list ,它应该可以工作,但是我找不到页面。

I've seen people suggest that it could be to do with the .htaccess file which is currently as default: 我见过有人建议,这可能与当前默认的.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]

I've also seen people suggest that you have to edit the /etc/apache2/httpd.conf file, to set AllowOverride all instead of AllowOverride none but either this doesn't work or i am doing it incorrectly, i've tried a few variations, ending up with this: 我还看到有人建议您必须编辑/etc/apache2/httpd.conf文件,以AllowOverride all设置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>

assuming this is the right fix i need, can someone point me out where im going wrong? 假设这是我需要的正确解决方法,有人可以指出我的错误之处吗? or suggest how to fix this issue. 或建议如何解决此问题。 As there are a few directory listings in the conf, is possible im changing the wrong one? 由于conf中有一些目录列表,可能会更改错误的目录列表吗?

This problem caused by the routing match. 由路由匹配引起的此问题。

If you mentioned like 'route' => '/list', , then it looks from localhost. 如果您提到'route'=>'/ list' ,,那么它看起来是从本地主机开始的。 But, list is one module under your ~adam project. 但是,列表是〜adam项目下的一个模块。

To solve this issue, create a Virtual Host. 要解决此问题,请创建一个虚拟主机。 If you are using Virutal Host then "/list" will look up from your (Virtual) Host name. 如果您使用的是Virutal Host,则将从您的(虚拟)主机名中查找“ / list”。

Otherwise, you have specify like this, 否则,您可以这样指定:

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

But this is the bad approach. 但这是不好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM