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

时间:2022-03-28 11:04:23

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 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中有一些目录列表,有可能我改错了吗?

1 个解决方案

#1


0  

This problem caused by the routing match.

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

If you mentioned like 'route' => '/list', , then it looks from localhost. But, list is one module under your ~adam project.

如果你提到'route'=>'/ list',那么它从localhost看起来。但是,list是~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.

但这是不好的方法。

#1


0  

This problem caused by the routing match.

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

If you mentioned like 'route' => '/list', , then it looks from localhost. But, list is one module under your ~adam project.

如果你提到'route'=>'/ list',那么它从localhost看起来。但是,list是~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.

但这是不好的方法。